# How does Mathematica compute how to write integers as the sum of k non-negative pth integer powers so quickly?

"PowersRepresentations[n,k,p] gives the distinct representations of the integer n as a sum of k non-negative p-th integer powers"

Documentation: PowersRepresentations

How does Mathematica do this computation so quickly? Is there a fast algorithm? What is it?

I am particularly interested in the case where $n$ is the sum of $k$ squares of positive integers.

• There is a little man inside the computer who is good at sums – wolfies Dec 5 '16 at 4:43

You can view the code for PowersRepresentations using
Needs["GeneralUtilities"];
`