Skip to main content
added 256 characters in body
Source Link
DJMcMayhem
  • 59.6k
  • 17
  • 196
  • 348

MATL, 5 bytes

t:Ysm

Try it online!

Explanation:

t       % Duplicate input
 :      % Range(1, input)
  Ys    % Cumulative sum. This will push the first *n* triangular numbers
    m   % ismember. Pushes true if the input is contained within the array we just pushed

MATL, 5 bytes

t:Ysm

Try it online!

MATL, 5 bytes

t:Ysm

Try it online!

Explanation:

t       % Duplicate input
 :      % Range(1, input)
  Ys    % Cumulative sum. This will push the first *n* triangular numbers
    m   % ismember. Pushes true if the input is contained within the array we just pushed
Source Link
DJMcMayhem
  • 59.6k
  • 17
  • 196
  • 348

MATL, 5 bytes

t:Ysm

Try it online!