#In C/C++, I can have the following loop#
for(int j = i * i; j <= N ;j += i)
#How do the same thing in Python?#
1 Answer
this might work:
from itertools import count
N = 11**2
i = 2
for j in count(start=i**2, step=i):
if j**2 > N:
break
print(j)
itertools.count starts at i**2 this way and counts up in steps of i. then i use the break statement to break the loop if the condition j**2 > N is met.