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

3 of 3
edited body
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's float precision for square roots easily suffices for the challenge limits of n up to a million, first giving a false positive on n=6896076976160002 as found by Deadcode.

xnor
  • 149.6k
  • 26
  • 287
  • 676

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