project-euler/124_ordered_radicals.py

15 lines
315 B
Python

#!/usr/bin/env python3
def radicals(n):
sieve = [1]*(n+1)
for p in range(2,n+1):
if sieve[p] > 1:
continue
for m in range(p, n+1, p):
sieve[m] *= p
return zip(range(n+1), sieve)
rads = list(radicals(10**5))
rads.sort(key = lambda x: x[1])
print(rads[10**4][0])