Thank goodness Python has a sort function! This would have been crazy hard without that.
def isprime(n):
if n == 0 or n == 1: return False
for i in range(2, int(n**0.5 + 1)):
if n%i == 0: return False
return True
primes = []
for n in range(10**5):
if isprime(n) == True:
primes.append(n)
def rad(n):
ans = 1
for p in primes:
if n%p == 0:
ans *= p
if p > n:
break
return ans
a = []
for n in range(1, 10**5+1):
if n%1000 == 0: print n
a.append([rad(n), n])
print (sorted(a))[10**4-1][1]