Skip to main content
deleted 14 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

Octave, 23 bytes

@(n)sum(1:sqrt(2*n))==n

This is an anonyous function that returns true (displayed as 1) for triangular numbers and false (0) otherwise.

Try it online!

Octave, 23 bytes

@(n)sum(1:sqrt(2*n))==n

Try it online!

Octave, 23 bytes

@(n)sum(1:sqrt(2*n))==n

This is an anonyous function that returns true (displayed as 1) for triangular numbers and false (0) otherwise.

Try it online!

deleted 14 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

Octave, 3223 bytes

@(n)nnz(pdist(sum(01:sqrt(2*n)^.5)'))==n

Try it online!Try it online!

Octave, 32 bytes

@(n)nnz(pdist((0:(2*n)^.5)'))==n

Try it online!

Octave, 23 bytes

@(n)sum(1:sqrt(2*n))==n

Try it online!

Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

Octave, 32 bytes

@(n)nnz(pdist((0:(2*n)^.5)'))==n

Try it online!