Your current approach won't work for the time constraint - it'll just take too long to complete.
Try this code first and figure out what's the trick
to save computing time.
primes = [2,3,5,7,11,13,17,19]
prod = 1
for p in primes:
n = 2
prod *= p
while (p**n < 21):
prod *= p
n += 1
print(prod) # 232_792_560
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…