A function f(n), that for any n gives the sum of 1^2 up to n^2?

111 Views Asked by At

I was solving Project Euler's problem # 6, where one has to find the sum of square of numbers from 1 to 100. I solved it using code and downloaded the Overview provided, to learn from it but I can't understand how the author has formed the function for finding the sum of square of numbers from 1 to n.

I've attached an image, highlighting the part of the document I don't understand. I know this is something really straightforward but I don't get it.

Please help and thanks in advance.

enter image description here

1

There are 1 best solutions below

8
On BEST ANSWER

$$f(0)=a(0)^3+b(0)^2+c(0)+d=d$$ $$f(1)=a(1)^3+b(1)^2+c(1)+d=a+b+c+d$$ $$f(2)=a(2)^3+b(2)^2+c(2)+d=8a+4b+2c+d$$ $$f(3)=a(3)^3+b(3)^2+c(3)+d=27a+9b+3c+d$$

Have you understood this much? After this, the numeric values of $f(0)$, $f(1)$, $f(2)$ and $f(3)$ have been found manually.

This gives us 4 equations that can be solved.