Advertisement
danchaofan

Euler #124

Dec 25th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. def factorize(n):
  2.     factors = []
  3.     while n % 2 == 0:
  4.         factors.append(2)
  5.         n = int(n/2)
  6.     for b in range(3, int(n**0.5) + 1, 2):
  7.         while n % b == 0:
  8.             n = int(n/b)
  9.             factors.append(b)
  10.     if n > 2:
  11.         factors.append(int(n))
  12.     product = 1
  13.     for c in set(factors):
  14.         product *= c
  15.     return product
  16.  
  17. nums, facprods = [1], [1]
  18. for x in range(2, 10**5+1):
  19.     print(x)
  20.     nums.append(x)
  21.     facprods.append(factorize(x))
  22. print(sorted(list(zip(facprods, nums)))[9999][1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement