Skip to main content
edited body
Source Link
Stewie Griffin
  • 46.5k
  • 13
  • 132
  • 295

Octave, 47 40 33 bytes

@(n)[k=(n^3-n)/6,k,-k-1,1-k,n].^3

Try it online!

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:

  1. Since n - n^3 = n(1-n)(1+n) then 6 | (n - n^3) and we can write n - n^3 = 6k.
  2. 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.

Octave, 47 40 33 bytes

@(n)[k=(n^3-n)/6,k,-k-1,1-k,n].^3

Try it online!

Saved 6 bytes thanks to rafa11111, since I had forgotten to remove some old parentheses. Saved another bytes by changing the signs, thanks to Giuseppe.

Uses the formula in the linked math.se post:

  1. Since n - n^3 = n(1-n)(1+n) then 6 | (n - n^3) and we can write n - n^3 = 6k.
  2. 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.

Octave, 47 40 33 bytes

@(n)[k=(n^3-n)/6,k,-k-1,1-k,n].^3

Try it online!

Saved 6 bytes thanks to Giuseppe, since I had forgotten to remove some old parentheses. Saved another bytes by changing the signs, thanks to rafa11111.

Uses the formula in the linked math.se post:

  1. Since n - n^3 = n(1-n)(1+n) then 6 | (n - n^3) and we can write n - n^3 = 6k.
  2. 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.

added 233 characters in body
Source Link
Stewie Griffin
  • 46.5k
  • 13
  • 132
  • 295

Octave, 47 4040 33 bytes

@(n)[-(k=[k=(n-n^3-n)/6),-k,(k+1),(-k-1),1-k,n].^3

Try it online!Try it online!

Saved 6 bytes thanks to rafa11111, since I had forgotten to remove some old parentheses. Saved another bytes by changing the signs, thanks to Giuseppe.

Uses the formula in the linked math.se post:

  1. Since n - n^3 = n(1-n)(1+n) then 6 | (n - n^3) and we can write n - n^3 = 6k.
  2. 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.

Octave, 47 40 bytes

@(n)[-(k=(n-n^3)/6),-k,(k+1),(k-1),n].^3

Try it online!

Uses the formula in the linked math.se post:

  1. Since n - n^3 = n(1-n)(1+n) then 6 | (n - n^3) and we can write n - n^3 = 6k.
  2. 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.

Octave, 47 40 33 bytes

@(n)[k=(n^3-n)/6,k,-k-1,1-k,n].^3

Try it online!

Saved 6 bytes thanks to rafa11111, since I had forgotten to remove some old parentheses. Saved another bytes by changing the signs, thanks to Giuseppe.

Uses the formula in the linked math.se post:

  1. Since n - n^3 = n(1-n)(1+n) then 6 | (n - n^3) and we can write n - n^3 = 6k.
  2. 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.

added 205 characters in body
Source Link
Stewie Griffin
  • 46.5k
  • 13
  • 132
  • 295

Octave, 4747 40 bytes

@(n)[-(k=(n-n^3)/6)^3,-k^3k,(k+1)^3,(k-1)^3,n^3]n].^3

Try it online!Try it online!

Uses the formula in the linked math.se post:

  1. Since n - n^3 = n(1-n)(1+n) then 6 | (n - n^3) and we can write n - n^3 = 6k.
  2. 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.

Octave, 47 bytes

@(n)[-(k=(n-n^3)/6)^3,-k^3,(k+1)^3,(k-1)^3,n^3]

Try it online!

Uses the formula in the linked math.se post:

  1. Since n - n^3 = n(1-n)(1+n) then 6 | (n - n^3) and we can write n - n^3 = 6k.
  2. 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.

Octave, 47 40 bytes

@(n)[-(k=(n-n^3)/6),-k,(k+1),(k-1),n].^3

Try it online!

Uses the formula in the linked math.se post:

  1. Since n - n^3 = n(1-n)(1+n) then 6 | (n - n^3) and we can write n - n^3 = 6k.
  2. 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.

added 162 characters in body
Source Link
Stewie Griffin
  • 46.5k
  • 13
  • 132
  • 295
Loading
Source Link
Stewie Griffin
  • 46.5k
  • 13
  • 132
  • 295
Loading