Partitions into perfect kth prime powers
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!
I'm confused: first, 3^2 + 3^2 + 2^2 is not 24, and second, 4 is not a prime, so 4^2 is not the square of a prime. Shouldn't pp^2(24) = 1?