fork download
  1. primes = [] # this will contain the primes in the end
  2. upto = 100 # the limit, inclusive
  3. for n in range(2, upto + 1):
  4. for divisor in range(2, n):
  5. if n % divisor == 0:
  6. break
  7. else:
  8. primes.append(n)
  9. print(primes)
Success #stdin #stdout 0s 23296KB
stdin
Standard input is empty
stdout
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]