Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Partitions into perfect kth prime powers

I am trying to return partitions of $n$ into perfect $k$th powers of primes, call the function $pp^k(n)$ where $k$ is the $k$th power, so for instance $pp^2(24)=3$ since $24=2^2+2^2+2^2+2^2+2^2+2^2=3^2+3^2+2^2=4^2+2^2+2^2$. I have the code that returns prime partitions of $n$ but I cannot figure out how to tweak it to return perfect $k$th 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!