Advertisement
danchaofan

Euler #69

Dec 9th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. def prime(n):
  2.     if n == 2 or n == 3: return True
  3.     if n < 2 or n % 2 == 0: return False
  4.     if n < 9: return True
  5.     if n % 3 == 0: return False
  6.     r = int(n**0.5)
  7.     f = 5
  8.     while f <= r:
  9.         if n % f == 0: return False
  10.         if n % (f+2) == 0: return False
  11.         f += 6
  12.     return True
  13.  
  14. primes, product, index = [], 1, 0
  15. for x in range(500001):
  16.     if prime(x):
  17.         primes.append(x)
  18.  
  19. while product < 10**6:
  20.     product *= primes[index]
  21.     if product > 10**6:
  22.         print(product/primes[index])
  23.         quit()
  24.     index += 1
  25. print(product)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement