Task
Your task is simple, generate a sequence that, given index i
, the value on that position is the sum of squares from 0
upto i
where i >= 0
.
Example:
Input: 0
Output: 0 (0^2)
Input: 4
Output: 30 (0^2 + 1^2 + 2^2 + 3^2 + 4^2)
Input: 5
Output: 55 (0^2 + 1^2 + 2^2 + 3^2 + 4^2 + 5^2)
Specification:
- You may take no input and output the sequence indefinitely;
- You may take input
N
and output theNth
element of the sequence; - You may take input
N
and output the firstN
elements of the sequence.
f(1) == 1 * 1 (1)
, andf(24) == 70 * 70 (4900)
. \$\endgroup\$f(1) = 1
? \$\endgroup\$f(0) = 0
. i've pointed out that to the few answers that failed that requirement \$\endgroup\$f(0) = 0
requirement ruined a few of my solutions :( \$\endgroup\$