I have the following code:
def isPP(n): pos = [int(i) for i in range(n+1)] pos = pos[2:] ##to ignore the trivial n** 1 == n case y = [] for i in pos:
IIRC, it's far easier to iteratively check "Does it have a square root? Does it have a cube root? Does it have a fourth root? ..." You will very quickly get to the point where putative roots have to be between 1 and 2, at which point you can stop.
1
2