The to the power of is straight forward i think
for x in range(1,22)
print x*x But the primary numbers has got me, :p
I was thinking of checking to see if a base number was equal to the number given, if not add another number and check again, but it seems sloppy..