Skip to main content
2 of 2
deleted 10 characters in body
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina 0.8.2, 26 bytes

.+ $* (^(1)|(?<2>1\2)\1)+$ 

Try it online! Link includes test cases. Explanation: The first stage just converts to unary; the second stage adds successive triangular numbers to see if this will exactly consume the unary number. The ?<2> syntax reuses capturing group 2; the equivalent in Perl is to use alternative capture group numbering:

Perl 5 -p, 33 bytes

$_=(1x$_)=~/((?|^(1)|(1\2)\1))+$/ 

Try it online! Link includes test cases.

Neil
  • 184.4k
  • 12
  • 76
  • 290