><>, 30 bytes
Assumes input is on the stack. Outputs either a 1
or 0
.
1v
<+1~v!?(}:{:,2*+1::
;n={<
This was fun. I'm new to ><>, and I'd welcome any suggestions for golfing.
This starts with n=1
, then continually increments n
while n(n-1)/2
is less than the input number. Once the loop terminates, it prints 1
if n(n-1)/2
is equal to the input number, 0
otherwise.