I am trying to return partitions of n into perfect kth powers of primes, call the function ppk(n) where k is the kth power, so for instance pp2(24)=3 since 24=22+22+22+22+22+22=32+32+22=42+22+22. I have the code that returns prime partitions of n but I cannot figure out how to tweak it to return perfect kth powers.
def pp(n):
return Partitions(n,parts_in=prime_range(n+1)).cardinality:
for n in srange(1,100):
print(n,pp(n))
Can someone please help. Thank you so much!