Octave, 47 40 33 bytes
@(n)[k=(n^3-n)/6,k,-k-1,1-k,n].^3
Saved 6 bytes thanks to rafa11111Giuseppe, since I had forgotten to remove some old parentheses. Saved another bytes by changing the signs, thanks to Giusepperafa11111.
Uses the formula in the linked math.se post:
- Since n - n^3 = n(1-n)(1+n) then 6 | (n - n^3) and we can write n - n^3 = 6k.
- 6k = (k+1)^3 + (k-1)^3 - k^3 - k^3.
It appears to be longer if I try to solve the equation: (n-n^3)=(k+1)^3 + (k-1)^3 - k^3 - k^3 with regards to k, instead of just using the equation.