fork(1) download
  1. def mod(a, b):
  2. global c
  3. c += 1
  4. return a % b
  5.  
  6. max = 1000
  7.  
  8. c = 0
  9. primes = filter(lambda p: all(mod(p, num) for num in range(2,p)),range(2,max))
  10. print c, 'divisions'
  11.  
  12. c = 0
  13. from math import sqrt
  14. primes = [2]
  15. for n in range(3, max, 2):
  16. if all(mod(n, p) for p in primes if p <= sqrt(n)):
  17. primes.append(n)
  18. print c, 'divisions'
Success #stdin #stdout 0.14s 10840KB
stdin
Standard input is empty
stdout
78021 divisions
2302 divisions