Calculate all the squares up to x using only addition and subtraction The goal is to calculate all the squares up to x with addition and subtraction.

Rules:


The code must be a function which takes the total number of squares to generate, and returns an array containing all those squares.
You can not use strings, structures, multiplication, division, or built-in functions for calculating squares.
You can only use arrays, integers (whole numbers), addition, subtraction. No other operators allowed!


This is a code-golf question, so the shortest code in bytes wins!
C, 55 52 bytes

int s(int n,int*r){for(int i=0,j=-1;n--;*r++=i+=j+=2);}


simply sums odd numbers


n: number of squares to compute
r: output array for storing the results
j: takes the successive values 1, 3, 5, 7, ...
i: is incremented by j on each iteration


Edit

4 chars can be saved using the implicit int declaration (>C99), but this costs 1 char because for initializers cannot contain a declaration in >C99. Then the code becomes

s(int n,int*r){int i=0,j=-1;for(;n--;*r++=i+=j+=2);}


Usage

void main() {
    int r[20];
    s(20, r);
    for (int i = 0; i &lt; 20 ; ++i) printf("%d\n", r[i]);
}  


Output

1
4
9
16
25
36
49
(...)
361
400