anyone know this simple algorithm

here the algorithm :
s = 0
for i=1 to n do
s = s+i*i

return s

first time i thought it was sieve of eratosthenes's algorithm but i don't even know what i am learning

one more thing, can anyone write the optimization for this algo?


please help
Last edited on
Write a program - try it out.

Fairly trivial exercise. Not much to optimize.

Hint: what's another way to write i * i?
Last edited on
Fairly trivial exercise. Not much to optimize
I strongly disagree.
∑[1, n](i^2) == 1/6 n (1 + n) (1 + 2 n)
Right - I got lost in the word algorithm as a set of instructions steps. . .
Last edited on
thanks guys, i helped
Topic archived. No new replies allowed.