Skip to main content
gave credit to dennis
Source Link
Neil A.
  • 2.1k
  • 7
  • 22

05AB1E, 77 6 bytes

EDIT: Thanks to @Dennis: Saved a byte because I forgot about the increment operator

8*1+t8*>t

Try it online!Try it online!

n is triangular if sqrt(8n + 1) is an integer

How it works

8* # multiply implicit input by 8
  1+> # add one
    t # sqrt
     .ï # is integer

05AB1E, 7 bytes

8*1+t

Try it online!

n is triangular if sqrt(8n + 1) is an integer

How it works

8* # multiply implicit input by 8
  1+ # add one
    t # sqrt
     .ï # is integer

05AB1E, 7 6 bytes

EDIT: Thanks to @Dennis: Saved a byte because I forgot about the increment operator

8*>t

Try it online!

n is triangular if sqrt(8n + 1) is an integer

How it works

8* # multiply implicit input by 8
  > # add one
   t # sqrt
    .ï # is integer
Source Link
Neil A.
  • 2.1k
  • 7
  • 22

05AB1E, 7 bytes

8*1+t.ï

Try it online!

n is triangular if sqrt(8n + 1) is an integer

How it works

8* # multiply implicit input by 8
  1+ # add one
    t # sqrt
     .ï # is integer