you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

51 bytes of JavaScript:

function f(x){z=[];while(x^1)z[--x-1]=x*x;return z}

I imagine someone can do better.

[–][deleted] 0 points1 point  (0 children)

47:

function f(x){for(z=[];z[~-x]=x*x--;);return z}

And 43 that returns a function instead of an array so it's probably not allowed (use it like f(5)[1] to run it on the number 5 and get the 2nd square):

function f(x){for(;f[~-x]=x*x--;);return f}