How can i find number of ways presenting number as sum of no more than 4 squares

67 Views Asked by At

I am given a number and I have to find number of ways to present that number as sum of no more than 4 squares.For example $25$ can be presented as $1^2+2^2+2^2+4^2$, $3^2+4^2$ and $5^2$.

1

There are 1 best solutions below

2
On

I would start with $n_1$, which can be represented in exactly one way ($1=1^2$) and try to come up with a recurrence of how to compute $n_{k+1}$ if all of $n_1, n_2, \ldots, n_k$ are available.