[Question]
  [
## Challenge
Given a positive integer, determine whether it is a triangular number, and accordingly output one of any two constant, distinct values.
### Definition
A [triangular number](https://en.wikipedia.org/wiki/Triangular_number) is a number that can be expressed as the sum of consecutive positive integers, starting at 1. They can also be expressed with the formula \$\frac {n(n + 1)} 2\$, where \$n\$ is some positive integer.
## Test cases
Truthy:
```
1
3
6
10
15
21
55
276
1540
2701
5050
7626
18915
71253
173166
222111
303031
307720
500500
998991
```
Falsy:
```
2
4
5
7
8
9
11
16
32
50
290
555
4576
31988
187394
501500
999999
```
## Rules
* Your entry may be a function or a program.
* You may assume that the input is a positive integer under \$10^6\$.
* You must pick two constant, distinct outputs to distinguish the two categories.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so **the shortest code in bytes in each language wins.**
  
[Answer]
# [Haskell](https://www.haskell.org/), 23 bytes
EDIT:
* -1 byte: @xnor got rid of parentheses with a `$`.
An anonymous function taking an `Int` and returning a `Char`.
Output is `'1'` for triangular numbers and `'0'` for others.
```
(!!)$show.(10^)=<<[0..]
```
[Try it online!](https://tio.run/nexus/haskell#JY3risJADIX/@xRH6Y@W4pBkOpeA9UVcF8pasbCOS@vi43cjm0BufCfnPkyln8pznIevZ/VbvqcyLu4@/NQfZX8sbbvD/ohd256u1TwOF5Rz416P@bKs177ebptquT1ermb6bPrD4UTOndeV4RHBBA4QRrCabA8d2UB2oEBIUeyW1ZjEEjw4eY4RIsJsH8jy3VISMoVJCKpZlTeCDqZChsJQjvBiCESNNLcumJ1nzdkMklejif/179j8AQ "Haskell – TIO Nexus")
* Use as `((!!)$show.(10^)=<<[0..]) 998991`.
* Generates the numbers 1, 10, 100, 1000, ..., converts those to strings, and concatenates them. Then indexes into the resulting infinite string
```
"1101001000100001000001000000...
```
[Answer]
# [Python](https://docs.python.org/2/), 24 bytes
```
lambda n:(8*n+1)**.5%1>0
```
[Try it online!](https://tio.run/nexus/python2#S7ON@Z@TmJuUkqiQZ6VhoZWnbaippaVnqmpoZ/A/Lb9IIU8hM0@hKDEvPVXDUMfSUlNBWyHa1MAAiIA8C0tLQx1TA0MIDwRirbg4C4oy80oU8nTSNPI0/wMA "Python 2 – TIO Nexus")
Outputs `False` for triangular numbers, `True` for the rest. Checks if `8*n+1` is a perfect square. Python's float precision for square roots easily suffices for the challenge limits of `n` up to a million, first giving a false positive on `n=6896076976160002` as found by Deadcode.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 [bytes](https://github.com/DennisMitchell/jelly)
```
R+\ċ
```
**[Try it online!](https://tio.run/nexus/jelly#@x@kHXOk@//RPYfbHzWtcf//P9pQx1jHTMfQQMfQVMfIUMcUSOqY6JjqmOtY6hga6hia6Rgb6ZgaxAIA "Jelly – TIO Nexus")**
### How?
```
R+\ċ - Main link: n
R    - range(n)   -> [1,2,3,...,N]
  \  - cumulative reduce by:
 +   -   addition -> [1,3,6,...,T(N)]
   ċ - count occurrences of right (n) in left -> 1 if triangular, 0 otherwise
```
[Answer]
## [Retina](https://github.com/m-ender/retina), 10 bytes
```
(^1|1\1)+$
```
Input is in unary. Output is `0` or `1`.
[Try it online!](https://tio.run/nexus/retina#FYvLCUMxEAPvU4cDTgyPle31p5dHSCHp3dlchDSMHvlzFdLr5Le@uvUs6RzRGMiQU4VHztjeLYoFMDfmqMHW/jt0nMliI6FBqyFRt8XZ6R73pr3WDw "Retina – TIO Nexus") (As a test suite that does decimal-to-unary conversion for convenience.)
### Explanation
This is the most basic exercise in forward-references. Most people are familiar with backreferences in regex, e.g. `(.)\1` to match a repeated character. However, some of the more advanced flavours allow you to use a backreference before or inside the group it's referring to. In that case, it's usually called a forward-reference. This can make sense if the reference is repeated. It might not be well defined on the first iteration, but on subsequent iterations, the later or surrounding group has captured something and can be reused.
This is most commonly used to implement recurrent patterns on unary strings. In this case, we try to match the input as the sum of consecutive integers:
```
(        # This is group 1, which we'll repeat 1 or more times.
  ^1     #   Group 1 either matches a single 1 at the beginning of the string.
|        # or
  1\1    #   It matches whatever the previous iteration matched, plus another
         #   1, thereby incrementing our counter.
         # Note that the first alternative only works on the first iteration
         # due to the anchor, and the second alternative only works *after*
         # the first iteration, because only then the reference is valid.
)+
$        # Finally, we make sure that we can exactly hit the end of the
         # string with this process.
```
[Answer]
# [Python 2](https://docs.python.org/2/), 25 bytes
Checks if (**8x+1**) is a square number.
```
lambda x:(8*x+1)**.5%1==0
```
[Try it online!](https://tio.run/nexus/python2#XZDNCsJADITvPkUvQltBkmy3uxH6Jl4qUhBURDz07Ws9yH66e5n8TGaSqRqq43Idb6fzWM2HOrfzTpu23cetDoMsj@fl/qqmWpvNF4YC@wJVgGPBBmZkPpEcO2FJSJKIWuqNvOzUSmoR7jQF7dFtZqpcRNb/E6dkQuVVGrF7dke/FdiBBT8FZoyBQ0xTOA1GF1B02uM5u8h7BvWceaYUnBZF/xb7vGZ5Aw "Python 2 – TIO Nexus")
[Answer]
## Mathematica, 16 bytes
```
OddQ@Sqrt[1+8#]&
```
Essentially a port of xnor's [Python solution](https://codegolf.stackexchange.com/a/122092/61980). Outputs `True` for triangular numbers, `False` otherwise.
[Answer]
## JavaScript (ES6), ~~30~~ 27 bytes
*Saved 2 bytes thanks to kamoroso94*
```
f=(n,k)=>n>0?f(n+~k,-~k):!n
```
### Test cases
```
f=(n,k)=>n>0?f(n+~k,-~k):!n
console.log('Testing truthy test cases');
console.log(f(1))
console.log(f(3))
console.log(f(6))
console.log(f(10))
console.log(f(15))
console.log(f(21))
console.log(f(55))
console.log(f(276))
console.log(f(1540))
console.log(f(2701))
console.log(f(5050))
console.log(f(7626))
console.log(f(18915))
console.log(f(71253))
console.log(f(173166))
console.log(f(222111))
console.log(f(303031))
console.log(f(307720))
console.log(f(500500))
console.log(f(998991))
console.log('Testing falsy test cases');
console.log(f(2))
console.log(f(4))
console.log(f(5))
console.log(f(7))
console.log(f(8))
console.log(f(9))
console.log(f(11))
console.log(f(16))
console.log(f(32))
console.log(f(50))
console.log(f(290))
console.log(f(555))
console.log(f(4576))
console.log(f(31988))
console.log(f(187394))
console.log(f(501500))
console.log(f(999999))
```
### Non-recursive version (ES7), 19 bytes
Port of [Adnan's answer](https://codegolf.stackexchange.com/a/122091/58563).
```
x=>(8*x+1)**.5%1==0
```
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 40 bytes
```
(([{}](((()))<>))<>){<>({}({}({})))}{}{}
```
[Wheat Wizard](http://chat.stackexchange.com/users/218449) and I had a [duel](https://codegolf.meta.stackexchange.com/q/12423/57100) over this question. When we decided to post our solutions we were tied at 42 bytes, but I found a 2 byte golf of his solution. We decided that would count as the tie breaker (my solution is below).
[Try it online!](https://tio.run/nexus/brain-flak#@6@hEV1dG6sBBJqamjZ2YFxtY6dRXQtBQNHaaiD8/9/QAAA "Brain-Flak – TIO Nexus")
### Explanation:
```
# Set up the stacks like this:  -input
                                     1     -input
                                     1          1
(([{}](((()))<>))<>)                 ^
# Output 1 for triangular and 0 for non-triangular 
{<>({}({}({})))}{}{}
```
For a full explanation please see [Wheat Wizard's answer](https://codegolf.stackexchange.com/a/122226/57100).
---
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 42 bytes
```
(([({})])<>){(({}())<>{}({})){((<>))}{}{}}
```
Outputs `0\n` (literal newline) for truthy, and the empty string for falsy.
The idea is to subtract 1 then 2 then 3 all the way up to the input. If you hit 0, then you know this is a triangular number, so you can stop there.
[Try it online! (truthy)](https://tio.run/##SypKzMzTTctJzP7/X0MjWqO6VjNW08ZOs1oDyNTQBDKBFFAQJAAU1qytBsLa//9NTQE "Brain-Flak – Try It Online")  
[Try it online! (falsy)](https://tio.run/##SypKzMzTTctJzP7/X0MjWqO6VjNW08ZOs1oDyNTQBDKBFFAQJAAU1qytBsLa//9NzQA "Brain-Flak – Try It Online")
```
# Push -input on both stacks. One is a counter and the other is a running total
(([({})])<>)
# Count up from -input to 0
{
  # Push the new total which is: (counter += 1) + total (popped) + input (not popped)
  # This effectively adds 1, then 2, then 3 and so on to the running total
  (({}())<>{}({}))
  # If not 0
  {
    # Push to 0s and switch stacks to "protect" the other values
    ((<>))
  # End if
  }
  # Pop the two 0s, or empty the stack if we hit 0
  {}{}
# End loop
}
```
---
### Here's a 46 byte solution that I found interesting.
```
{<>(({}())){({}[()]<>{(<({}[()])>)}{}<>)}{}<>}
```
Outputs `0\n` (literal newline) for truthy, the empty string for falsy.
The idea is to count down from input by consecutive numbers, 1 at a time. E.g. `input - (1) - (1,1) - (1,1,1)`. Each time we subtract, if we aren't at 0 yet, we leave an extra value on the stack. That way, if we are at 0 and are still subtracting when we pop we remove the last value on the stack. If the input was a triangular number, we will end exactly at 0, and wont pop the 0.
[Try it online! truthy](https://tio.run/##SypKzMzTTctJzP7/v9rGTkOjulZDU1OzGkhHa2jG2thVa9hA2Zp2mrXVtTZQsvb/f1MDUwMA "Brain-Flak – Try It Online")  
[Try it online! falsy](https://tio.run/##SypKzMzTTctJzP7/v9rGTkOjulZDU1OzGkhHa2jG2thVa9hA2Zp2mrXVtTZQsvb/fxNTczMA "Brain-Flak – Try It Online")
```
# Implicit input (call it I)
# Until we reach 0, or the stack is empty
{
  # Add 1 to the other stack and push it twice. This is our counter.
  <>(({}()))
  # While counter != 0
  {
    # counter -= 1
    ({}[()]
    # if I != 0 
    <>{
      # I -= 1, and push 0 to escape the if
      (<({}[()])>)
    # End if
    }
    # Pop from the stack with I. This is either the 0 from the if, or I
    {}
    # Get ready for next loop End while
    <>)
  # End While
  }
  # Pop the counter that we were subtracting from
  {}<>
# End Until we reach 0, or the stack is empty.
}
```
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 11 bytes
```
ri2*_mQ_)*=
```
Outputs `1` for triangular, `0` otherwise.
[Try it online!](https://tio.run/nexus/cjam#@1@UaaQVnxsYr6ll@/@/kSEA "CJam – TIO Nexus")
### Explanation
Consider input `21`.
```
ri               e# Input integer.             STACK: 21
  2*             e# Multiply by 2.             STACK: 42
    _            e# Duplicate.                 STACK: 42, 42
     mQ          e# Integer square root.       STACK: 42, 6
       _)        e# Duplicate, increment.      STACK: 42, 6, 7
         *       e# Multiply.                  STACK: 42, 42
          =      e# Equal?                     STACK: 1
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
×8‘Æ²
```
[Try it online!](https://tio.run/nexus/jelly#LY7LDQIxDETvVJECfLCdZB1XQBGr7QVxgBKgCE6UwHayjYQZRD4aa5w38dwf47g899vnPff7cX3hnOdcV5NSpSxSTHG7FIfTqUGzN2WpNLWjjsXpj@TbMO@gLaotcN3djIGK/dMIV5JAoZkj0zY5ldWlNDQQIWWggxAAhpDqBBCWJDlJ6xylWo7Bn6MmUbV/Jte2fQE "Jelly – TIO Nexus")
### Background
Let **n** be the input. If **n** is the **k**th triangular number, we have
$$ n = \frac{k(k+1)}{2} \iff k^2+k-2n = 0 \iff k = \frac12 (-1 \pm \sqrt{1+8n}), $$
which means there will be a natural solution if and only if **1 + 8n** is an odd, perfect square. Clearly, checking the parity of **1 + 8n** is not required.
### How it works
```
×8‘Æ²  Main link. Argument: n
×8     Yield 8n.
  ‘    Increment, yielding 8n + 1.
   Æ²  Test if the result is a perfect square.
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~31~~ 30 bytes
```
"$args"-in(1..1e6|%{($s+=$_)})
```
[Try it online!](https://tio.run/nexus/powershell#@6@kkliUXqykm5mnYainZ5hqVqNaraFSrG2rEq9Zq/n//39TAwMgAgA "PowerShell – TIO Nexus")
Nice and slow brute force method. Make an array of every sum of 1 through 106, and see if the argument is in there.
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 42 bytes
```
(([{}](<((())<>)>))<>){<>({}({}({})))}{}{}
```
[Try it online!](https://tio.run/nexus/brain-flak#@6@hEV1dG6tho6GhoalpY6dpByarbew0qmshSFNTs7YaCP//NzYDAA "Brain-Flak – TIO Nexus")
## Explanation
The goal of this program is to create a state on two stacks and perform constant operation on both stacks until one of them zeros, we can then output depending on which stack we are on. This is similar to programs that determine the sign of a number. These programs put `n` on one stack and `-n` on the other and add one and switch stacks until one of the stacks is zero. If the number was negative in the first place the first stack will hit zero, if the number was positive the other stack will hit zero.
Here we create two stacks one that subtracts consecutive numbers from the input and one that just subtracts one. The one that subtracts consecutive numbers will only terminate if the number is triangular, (other wise it will just pass zero and keep going into the negatives). The other one will always terminate for any positive number, but will always do so slower than the first, thus non-triangular numbers will terminate on that stack.
So how do we set up stacks so that the same operation subtracts consecutive numbers on one and subtracts one on the other? On each stack we have the input on top so that in can be checked, below that we have the difference and below that we have the difference of the difference. Each time we run we add the "difference of the difference" to the regular "difference" and subtract that from the input. For the stack that checks for triangularity we set our double difference to be `1` so that we get consecutive integers each time we run, for the other stack we set it to `0` so that we never change the difference, that is it always stays 1. Here is how the stack is set up at the beginning, where `n` is the input:
```
-n  -n
 0   1
 1   0
```
When we finally do terminate we can use these differences to check which stack we are on we pop the top two values and we get `1` for a triangular number and `0` for a non-triangular number.
---
### Annotated code
```
(([{}](<((())<>)>))<>) Set up the stack
{                      While
 <>                    Switch stacks
 ({}({}({})))          Add bottom to second to bottom, add second to bottom to top
}                      End while
{}{}                   Pop the top two values
```
---
Here's a 50 byte solution I like as well.
```
{(({}[()]))}(([[]])<>){({}{}())<>}({}{()<><{}>}{})
```
[Try it online!](https://tio.run/nexus/brain-flak#FcixCQAwDAPBdaQuTbqQRYwnEZrdUeCL40eAXGCTBqq6eS6VKYOxPxEc@WZyZq@VHg "Brain-Flak – TIO Nexus")
[Answer]
# [Cubix](https://github.com/ETHproductions/cubix), 23 ~~24~~ ~~25~~ bytes
```
I1Wq/)s.;0..s;p-?\.+O@u
```
0 for truthy and nothing ~~0~~ for falsey. Brutes forces by incrementing counter, adding to cumulative sum and comparing to input. ~~Now to try and fit it on a 2x2x2 cube.~~ Did it!
```
    I 1
    W q
/ ) s . ; 0 . .
s ; p - ? \ . +
    O @
    u .
```
[Try it online!](https://tio.run/nexus/cubix#@@9pGF6or1msZ22gp1dsXaBrH6On7e9Q@v@/IQA "Cubix – TIO Nexus")
* `/` Reflect to to face.
* `I10\` get integer input, push 1 (counter), push 0 (sum) and reflect
* `+s;p-` loop body. Add sum and counter, drop previous sum, raise input and subtract
* `?` Test the result of the subtraction
	+ For 0 result carrying on straight ahead `\.uO@` reflect to bottom face, no-op, U-turn, output and halt.
	+ For positive result turn right onto bottom face and `@` halt
	+ For negative result turn left `;qWs)/su` drop subtraction, put input to bottom, shift left, swap counter and sum, increment counter, reflect, swap sum and counter, U-turn onto main loop body.
[Answer]
# [R](https://www.r-project.org/), ~~23~~ 19 bytes
Similar approach as other answers. Checks to see if `8x+1` is a perfect square.  
 -4 bytes thanks Giuseppe and MickyT.
```
!(8*scan()+1)^.5%%1
```
[Try it online!](https://tio.run/##JY1LCgJBDET3dQsXAzMKkkp3Op3LCOLehd6ftgYTyI9Xqc9al31ev6/nez9uPB732DYuomGABgacCNXUHt00mA4Whhyu2ywxSY8GZuMYcHdSH0x5tkw3KSQxVM0qwtEhFSYKQjnQXAi8RMqth@waa04ZZCvRxr/@jPUD "R – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), 5 bytes
```
t:Ysm
```
[Try it online!](https://tio.run/nexus/matl#@19iFVmc@/@/oQEA "MATL – TIO Nexus")
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
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~7~~ 6 bytes
**EDIT**: Thanks to @Dennis: Saved a byte because I forgot about the increment operator
```
8*>t.ï
```
[Try it online!](https://tio.run/##MzBNTDJM/f/fQsuuRO/w@v//zQA "05AB1E – 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
```
[Answer]
# [Perl 6](http://perl6.org/), 17 bytes
```
{$_∈[\+] 1..$_}
```
Just checks whether `$_`, the input to the function, is equal to any of the elements of the triangular addition reduction `(1, 1+2, ..., 1+2+...+$_)`.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 5 bytes
```
≥ℕ⟦+?
```
[Try it online!](https://tio.run/nexus/brachylog2#@/@oc@mjlqmP5i/Ttv//39AUAA "Brachylog – TIO Nexus")
## Explanation
```
≥ℕ⟦+?
≥ℕ     There is a number from 0 to {the input} inclusive
  ⟦    such that the range from 0 to that number
   +   has a sum
    ?  that equals the input
```
[Answer]
# [Alice](https://github.com/m-ender/alice), ~~38~~ 22 bytes
*A lot of bytes saved thanks to Martin and Leo*
```
/ i \2*.2RE.h*-n/ o @
```
There is a trailing newline. Outputs `1` for triangular, `0` otherwise.
[Try it online!](https://tio.run/nexus/alice#@6@vkKkQY6SlZxTkqpehpZunr5Cv4MD1/7@hKQA)
### Explanation
This uses the same approach as my [CJam answer](https://codegolf.stackexchange.com/a/122096/36398), only clumsier. In linearized form, the program becomes
```
i2*.2RE.h*-no@
```
where the `i` and `o` are actually in ordinal mode.
Consider input `21` as an example.
```
i         Input integer                       STACK: 21
2*        Multiply by 2                       STACK: 42
.         Duplicate                           STACK: 42, 42
2RE       Integer square root                 STACK: 42, 6
.         Duplicate                           STACK: 42, 6, 6
h         Increment                           STACK: 42, 6, 7
*         Multiply                            STACK: 42, 42
-         Subtract                            STACK: 0
n         Logical negation                    STACK: 1
o         Output integer                      STACK:
@         End program
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 10 7 bytes
*Saved 3 bytes thanks to @Luke and @ETHproductions*
```
*8Ä ¬v1
```
[Try it online!](https://tio.run/nexus/japt#@69lcbhF4dCaMsP//w0B)
### Explanation:
```
*8Ä ¬v1
    ¬    // Square root of:
*8       //   Input * 8
  Ä      //   +1
     v1  // Return 1 if divisible by 1; Else, return 0
```
---
```
õ å+ øU
```
### Explanation:
```
õ å+ øU
õ           // Create a range from [1...Input]
  å+        // Cumulative reduce by addition
     øU     // Does it contain the input?
```
[Try it online!](https://tio.run/##y0osKPn///BWhcNLtRUO7wj9/183N4iLK9pQh8tYh8tMh8vQAIhNdbiMgCKmINocJGhqYgBiGhjqACkdLhOgnA6XuQ6XhQ6XJVAaqNYQqMwYKGVqEAsA)
[Answer]
# [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/tree/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b), 4 bytes
```
ÅTs¢
```
[Try it online!](https://tio.run/##MzBNTDJM/f//cGtI8aFF//@bAQA "05AB1E (legacy) – Try It Online")
Explanation:
```
ÅT     //push all triangle numbers <= (implicit) input
  s    //push input onto stack
   ¢   //count occurrences of input in triangle numbers (i.e. 1 if triangle, 0 if not)
```
I'm using 05AB1E (legacy) since it pre-dates this challenge, but it works in current 05AB1E as well
[Answer]
# [TypeScript](https://www.typescriptlang.org/)’s type system, 91 bytes
```
//@ts-ignore
type F<N,A=[],I=N["length"]>=N extends[...infer R,0]?F<R,[1,...R,...A],I>:A[I]
```
[Try it at the TS playground](https://www.typescriptlang.org/play?#code/PTACBcGcFoEsHMB2B7ATgUwLAChwE8AHdAAgDEAeAOQBoBBAXgG0BdagSXssYCIAbdRPHAALbswB8nYugAe4AQBNIjAHRrYiAGbpUxAErUADMwD8FA4wCM1NSoO3arNuIBctRm2Y5vuQiQAq6JDgAGzE9GTkjIZGsTHxEjggxCnEAHomOPhExIHBAJzhkdFxpfFxidjJqRlZfrlB4JaGRRQl5R1lRpXVKbXYQA)
This is a generic type `F` taking a unary number `N` as a tuple of N zeroes. I never would have expected a challenge like this to be under 100 bytes in TS types, but in this instance it’s quite doable. This is almost definitely ungolfable.
This works by creating the string `1101001000100001…`, which contains N ones separated by as many zeroes as there are already added ones, and indexing into this string with N.
Explanation of the code:
```
//@ts-ignore - Suppress any type errors on the following line.
type F<
  N,            // N is a tuple type of 0s
  A=[],         // A becomes the string, starts as an empty list
  I=N["length"] // I is the original N which we use to index at the end
>=
  N extends[...infer R,0] // If a 0 fits in N, take the difference R (i.e. decrement)
    ?F<R,            // If that succeeded, recurse with N = R,
      [1,...R,...A], // A with 1 then R prepended,
    I>               // and I kept as it was.
  :A[I] // If it failed, N is 0, so index into A with the original number.
```
[Answer]
## Batch, 72 bytes
```
@set/aj=i=0
:l
@if %1% gtr %j% set/aj+=i+=1&goto l
@if %1==%j% echo 1
```
Outputs 1 on success, nothing on failure. Works for zero too, although not requested by the question for some reason.
[Answer]
# JavaScript (ES7), ~~19~~ 18 bytes
From [my answer](https://codegolf.stackexchange.com/a/119011/58974) to a [related question](https://codegolf.stackexchange.com/q/118980/58974).
Outputs `false` for triangular numbers or `true` for non-triangular, as permitted by the OP.
```
n=>(8*n+1)**.5%1>0
```
---
## Try It
```
f=
n=>(8*n+1)**.5%1>0
oninput=_=>o.innerText=f(+i.value)
```
```
<input id=i type=number><pre id=o>
```
[Answer]
# PHP, 30 Bytes
Prints 1 for true and nothing for false
```
<?=fmod(sqrt(8*$argn+1),2)==1;
```
[Try it online!](https://tio.run/nexus/php#s7EvyCjgUkksSs@zNTOz5rK3@29jb5uWm5@iUVxYVKJhoQWW0zbU1DHStLU1tP7/HwA "PHP – TIO Nexus")
[fmod](http://php.net/manual/en/function.fmod.php)
# PHP, 37 Bytes
Prints 1 for true and nothing for false
```
<?=($x=sqrt($q=2*$argn)^0)*$x+$x==$q;
```
[Try it online!](https://tio.run/nexus/php#s7EvyCjgUkksSs@zNTOz5rK3@29jb6uhUmFbXFhUoqFSaGukBZbVjDPQ1FKp0AbK2KoUWv//DwA "PHP – TIO Nexus")
[Answer]
## Mathematica, 28 bytes
```
!Accumulate@Range@#~FreeQ~#&
```
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 18 bytes
```
n->issquare(8*n+1)
```
[Try it online!](https://tio.run/nexus/pari-gp#LY5BC8IwDIX/Sthp1Q6adF2bg/sj4mEHBwMpc9ODv36@iC0l6cd7L5npQkftxmXfn@9pu7flVM/sjmldH5@2UjfSui31hbaxT0NzW53zdGVP0dPgiQNe8iQgyWo2mPpgbTAYEvo8iPGips0sCW7OkQdQEWG2wID7qzlLMCesqKpFFVw89aDweyrASABlJEQxNRRqNlujT7ZHZC3FxuaoZg38D7Rzc8cX "Pari/GP – TIO Nexus")
---
There is a built-in to test if a number is a polygonal number, but it is one byte longer.
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 19 bytes
```
n->ispolygonal(n,3)
```
[Try it online!](https://tio.run/nexus/pari-gp#LY6xCsMwDER/RWSKwQFLjmNraH6kdMiSEgiOabvk69NTqY2R/Lg7aaUbXXWYt3c79vN51GXvq4/uWlrbz77SMFN7bfWDtrNPR2tfnfN0Z0/R0@SJA17yJCDJajaYxmBtMBgS@jyJ8aKmzSwJbs6RJ1ARYbbAgPurOUswJ6yoqkUVXDyNoPB7KsBIAGUkRDE1FGo2W2NMtkdkLcXG5qhmDfwPtPNw1xc "Pari/GP – TIO Nexus")
[Answer]
# Python - 52 bytes
***Note:*** *I know that the other two Python answers are much shorter, but this is the old-school way, more of a by-hand algorithm*
```
n=input();i=s=0
while s<n:s=(i*i+i)/2;i+=1
print s>n
```
[Answer]
# Excel, ~~31~~ 22 bytes
9 bytes saved thanks to Octopus
Outputs `TRUE` for triangular numbers. Else `FALSE`. Checks if `8*n+1` is a perfect square. 
```
=MOD(SQRT(8*B1+1),1)=0
```
[Answer]
# [Alchemist](https://github.com/bforte/Alchemist), 80 bytes
```
_->In_n+s
f+b->f+a
f+0b->a
0f+n+a->b
0f+0a+n->n+f
0n+a+s->Out_n
0n+0a+s->Out_"1"
```
[Try it online!](https://tio.run/##PcgxDoAgDEDRnWOwNk3q4tjdySOQohJJtJiA17fi4vb@l2PZtzPXZhaQJw0K1SWIyAmkg7rEUQIFQY6fSECRFZKjPqEiz3cL@hX96QdvNj7larloNVxf "Alchemist – Try It Online")
[Test cases](https://tio.run/##TY47C8IwFIVn8ysuIdJKiEaki4/sTjroJpQ0D1rQG23qpP722CIUt@8cOI9KxzoZ3W23mUObgQITrJubFlMp1B5L5JF4Xgnlue5B9qSJ9By5FqoaSGqOQiH3RPYmj0Idnl2Jg5KjpEua@gHiQwsIDQLLo3sAW842YAOZHM6n4/m0Y7kzdQCG8IZFuHcLfTW1uzXxj8aHMzK5tw12Huh0ZQGm8YJ0yFL2@vWtBXwosQFdSkXxBQ)
Subtracts increasing numbers from the input until it reaches 0, and checks if the counter is zero.
]