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 Revisions

1 of 3
xnor
  • 149.6k
  • 26
  • 287
  • 676

Python, 24 bytes

lambda n:(8*n+1)**.5%1>0

Try it online!

Outputs False for triangular numbers, True for the rest. Checks if 8*n+1 is a perfect square. Python will take perfect squares to exact integer floats no matter how large, so there are no floating-point issues.

xnor
  • 149.6k
  • 26
  • 287
  • 676

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