Files
Learn-Python-Programming-Th…/ch03/primes.py
T
adii1823 8b802c5c62 ch03
2021-10-28 17:34:45 +05:30

13 lines
365 B
Python

primes = [] # this will contain the primes in the end
upto = 100 # the limit, inclusive
for n in range(2, upto + 1):
is_prime = True # flag, new at each iteration of outer for
for divisor in range(2, n):
if n % divisor == 0:
is_prime = False
break
if is_prime: # check on flag
primes.append(n)
print(primes)