Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 5 characters in body
Source Link
TFeld
  • 19.9k
  • 3
  • 21
  • 63

Python 2, (削除) 32 (削除ここまで) 28(削除) 28 (削除ここまで) 25 bytes

lambda n:n*n/8(~-[nn|1)**2/4,-1][n%2]8+n%2

Try it online! Try it online!

Returns the n-th number (0-indexed)

Python 2, (削除) 32 (削除ここまで) 28 bytes

lambda n:n*n/8-[n/4,-1][n%2]

Try it online!

Returns the n-th number (0-indexed)

Python 2, (削除) 32 (削除ここまで) (削除) 28 (削除ここまで) 25 bytes

lambda n:(~-n|1)**2/8+n%2

Try it online!

Returns the n-th number (0-indexed)

added 7 characters in body
Source Link
TFeld
  • 19.9k
  • 3
  • 21
  • 63

Python 2, 32(削除) 32 (削除ここまで) 28 bytes

lambda n:(~-nn*n/2)*(~8-n/2+1)[n/2+n%24,-1][n%2]

Try it online! Try it online!

Returns the n-th number (0-indexed)

Python 2, 32 bytes

lambda n:(~-n/2)*(~-n/2+1)/2+n%2

Try it online!

Returns the n-th number (0-indexed)

Python 2, (削除) 32 (削除ここまで) 28 bytes

lambda n:n*n/8-[n/4,-1][n%2]

Try it online!

Returns the n-th number (0-indexed)

Source Link
TFeld
  • 19.9k
  • 3
  • 21
  • 63

Python 2, 32 bytes

lambda n:(~-n/2)*(~-n/2+1)/2+n%2

Try it online!

Returns the n-th number (0-indexed)

AltStyle によって変換されたページ (->オリジナル) /