from lib_prime import prime_factors def radical(n: int) -> int: fs = prime_factors(n) r = 1 for f in set(fs): r *= f return r def euler_124(): assert radical(504) == 42 xs = [] for n in range(1, 100001): xs.append((radical(n), n)) xs = sorted(xs) return xs[10000 - 1][1] if __name__ == "__main__": solution = euler_124() print("e124.py: " + str(solution)) assert(solution == 21417)