text:
ASCII Triangles
Your task is to write a program or a function that prints an ASCII triangle. They look like this:
|\
| \
|  \
----

Your program will take a single numeric input n, with the constraints 0 <= n <= 1000. The above triangle had a value of n=3.
The ASCII triangle will have n backslashes (\) and vertical bars (|), n+1 lines and dashes (-), and each line will have an amount of spaces equal to the line number (0-based, ie first line is line 0) besides the ultimate line.
Examples:
Input:
4

Output:
|\
| \
|  \
|   \
-----

Input:
0

Output:

In this test case, the output must be empty. No whitespace.
Input:
1

Output:
|\
--

Input & output must be exactly how I specified.
This is code-golf, so aim for the shortest code possible!

related

Does it need to be a program or can it be a function?

I think it would be better if case 0 can have any unexpected output since it is an edge case (especially since you requested that the number of dashes must be one more than the input number)

FYI: You can use

 to have an empty code block (so you don't need an (empty)

@TuukkaX as I said, output must be exactly as specified.

@LliwTelracs you can see in the top that I said a program.

@Okx There are frequently questions where the asker says program but really meant program or function. You might want to clarify that you are asking for a FULL program

@LliwTelracs changed. Do you think I should allow functions?

@Okx I feel it is your choice but would prefer that there wasn't the additional restriction.

I would definitely go for both program and function. That's the default rule if nothing else is specified. I would also remove the 0-edge case since it's a direct violation of "n+1 lines and dashes (-)".

The challenge would be too simple without the size=0 exception. Part of the challenge is figuring out a way to account for this with the least amount of extra code.

I second @12Me12 - even if not intended, the edge case gives an... edge to the challenge. And changing challenges posted after answers are submitted is bad form.

@StewieGriffin a single dash wouldn't be a triangle, would it? :P

Is it acceptable to return the string? Or is printing mandatory? Quite a few answers here (including mine) are returning a string to save a few bytes.

@adrianmp Since people have been doing both, I'd say you can return the string

I assume that PETSCII substitutes for the ASCII characters are okay if it's for a C64/PET/VIC-20 etc...?

My original idea for suppressing output for x = 0 was originally x and x+1 but apparently that's not very efficient...

Jelly, 14 bytes
’⁶x⁾|\jṄµ€Ṫ”-ṁ

Try it online!
How it works.
’⁶x⁾|\jṄµ€Ṫ”-ṁ  Main link. Argument: n

        µ       Combine the links to the left into a chain.
         €      Map the chain over [1, ..., n]; for each k:
’                 Decrement; yield k-1.
 ⁶x               Repeat the space character k-1 times, yielding a string.
   ⁾\j            Join the character array ['|', '\'], separating by those spaces.
      Ṅ           Print the result, followed by a linefeed.
         Ṫ      Tail; extract the last line.
                This will yield 0 if the array is empty.
          ⁾-ṁ   Mold the character '-' like that line (or 0), yielding a string
                of an equal amount of hyphen-minus characters.

C, 58 bytes
i;f(n){for(i=2*n;~i--;printf(i<n?"-":"|%*c\n",2*n-i,92));}

--
Thanks to @Steadybox who's comments on this answer helped me shave a few bytes in my above solution

I managed to reach 68, was pretty proud of myself.. and then I scrolled :( -- Well done!

Very nice! Have a +1

I have 2*n in there twice and it bothers me, can anyone think of a clever way to shorten it somehow?

-1 byte and fixes bug for n=0

@att Nice! I knew there'd be a way, wow 3 years later too!

Javascript (ES6), 97 85 81 75 74 bytes
n=>(g=(n,s)=>n?g(--n,`|${" ".repeat(n)}\\
`+s):s)(n,"")+"-".repeat(n&&n+1)

Turns out I wasn't using nearly enough recursion

f=n=>(g=(n,s)=>n?g(--n,`|${" ".repeat(n)}\\
`+s):s)(n,"")+"-".repeat(n&&n+1)

console.log(f(0))
console.log(f(1))
console.log(f(2))
console.log(f(3))
console.log(f(4))

05AB1E, 16 15 16 bytes
Saved a byte thanks to Adnan
FðN×…|ÿ\}Dg'-×»?

Try it online!
Explanation
F       }         # for N in range [0 ... input-1]
 ðN×              # push <space> repeated N times
    …|ÿ\          # to the middle of the string "|\"
         Dg       # get length of last string pushed
           '-×    # repeat "-" that many times
              »   # join strings by newline
               ?  # print without newline

ð×.svy¦…|ÿ\}¹>'-×», guess my idea of .s wasn't as good as I thought. Nice use of ÿ, haven't seen that before.

@carusocomputing: I considered .s as well as starting with <Ýð× but ran into trouble with the special case with those methods.

FðN×…|ÿ\}Dg'-×» for 15 bytes

@Adnan: Nice catch with Dg! Thanks :)

.s also resulted in nested arrays and flattening which required more bytes.

Trailing newlines not allowed, sorry!

@carusocomputing: Building the list with .p and then flattening would have saved a byte there. Still would have been two bytes or so longer than this.

@Okx: That is now fixed.

V, 18 17 16 bytes
1 byte saved thanks to @nmjcman101 for using another way of outputting nothing if the input is 0
é\é|ÀñÙá ñÒ-xÀ«D

Try it online!
Hexdump:
00000000: e95c e97c c0f1 d9e1 20f1 d22d 78c0 ab44  .\.|.... ..-x..D

Explanation (outdated)
We first have a loop to check if the argument is 0. If so, the code below executes (|\ is written). Otherwise, nothing is written and the buffer is empty.
Àñ     ñ            " Argument times do:
  é\é|              " Write |\
      h             " Exit loop by creating a breaking error

Now that we got the top of the triangle, we need to create its body.
Àñ   ñ              " Argument times do:
  Ù                 " Duplicate line, the cursor comes down
   à<SPACE>         " Append a space

Now we got one extra line at the bottom of the buffer. This has to be replaced with -s.
Ó-                  " Replace every character with a -
   x                " Delete the extra '-'

This answer would be shorter if we could whatever we want for input 0
V, 14 13 bytes
é\é|ÀñÙá ñÒ-x

Try it online!

I should not have tried that hard for a byte Try it online!

@nmjcman101 Ah, « of course. Clever! :)

C#, 93 bytes
n=>{var s=n>0?new string('-',n+1):"";while(n-->0)s="|"+new string(' ',n)+"\\\n"+s;return s;};

Anonymous function which returns the ASCII triangle as a string.
Full program with ungolfed, commented function and test cases:
using System;

class ASCIITriangles
{
    static void Main()
    {
      Func<int, string> f =
      n =>
      {
          // creates the triangle's bottom, made of dashes
          // or an empty string if n == 0
          var s = n > 0 ? new string('-', n + 1) : "";

          // a bottom to top process
          while ( n-- > 0)
          // that creates each precedent line
            s = "|" + new string(' ', n) + "\\\n" + s;

          // and returns the resulting ASCII art
          return s;
      };

      // test cases:
      Console.WriteLine(f(4));
      Console.WriteLine(f(0));
      Console.WriteLine(f(1));
    }
}

Python 2, 69 bytes
lambda x:'\n'.join(['|'+' '*n+'\\'for n in range(x)]+['-'*-~x*(x>0)])

Try it online!

If you're printing it, you can save a few bytes by changing to python3, removing "".join and replacing it with the * operator and the sep argument in the sleep function, so lambda x:print(*['|'+' '*n+'\\'for n in range(x)]+['-'*-~x*(x>0)],sep="\n")

PowerShell, 51 67 bytes
param($n)if($n){1..$n|%{"|"+" "*--$_+"\"};write-host -n ('-'*++$n)}

Try it online!
(Byte increase to account for no trailing newline)
Takes input $n and verifies it is non-zero. Then loops to construct the triangle, and finishes with a line of -. Implicit Write-Output happens at program completion.

The program prints a trailing newline but I asked output to be exactly as specified, sorry!

@Okx Changed at a cost of 16 bytes.

CJam, 24 22 21 bytes
Saved 1 byte thanks to Martin Ender
ri_{S*'|\'\N}%\_g+'-*

Try it online!
Explanation
ri                     e# Take an integer from input
  _                    e# Duplicate it
   {                   e# Map the following to the range from 0 to input-1
    S*                 e#   Put that many spaces
      '|               e#   Put a pipe
        \              e#   Swap the spaces and the pipe
         '\            e#   Put a backslash
           N           e#   Put a newline
            }%         e# (end of map block)
              \        e# Swap the top two stack elements (bring input to the top)
               _g+     e# Add the input's signum to itself. Effectively this increments any
                       e#  non-zero number and leaves zero as zero.
                  '-*  e# Put that many dashes

bash + printf, 68 bytes
for((;i<$1;))
{
a=$a-
printf "|%$[i++]s\\\\\n"
}
[ $a ] && echo $a-

Use "bash program_name number" to run. Sample run:
bash-4.1$ bash triangle 0
bash-4.1$ bash triangle 1
|\
--
bash-4.1$ bash triangle 2
|\
| \
---
bash-4.1$ bash triangle 3
|\
| \
|  \
----

Very nice. Shaved 3 bytes

Python 3, 60 bytes
f=lambda n,k=0:k<n and'|'+' '*k+'\\\n'+f(n,k+1)or'-'[:n]*-~n

Try it online!
Two more solutions with the same byte count.
f=lambda n,k=0:n and'|'+' '*k+'\\\n'+f(n-1,k+1)or-~k*'-'[:k]
f=lambda n,s='|':-~n*'-'[:n]if s[n:]else s+'\\\n'+f(n,s+' ')

dc, 98 bytes
256?dse1+d[q]st1=t^124*23562+dsaP2sk[[lkd256r^32*la+dsaPd1+skle>y]srle1<r]dsyx[45Ple1-dse0!>q]dsqx

Try it online!
Explanation
This takes due advantage of dc's P command, which utilizes conversion to base 256 on most systems. Therefore, for any input n, the program first raises 256 to the n + 1th power, multiplies the result by 124 (ASCII character |), and then adds 256*92+10=23562 to the product (where 92 is equivalent to the character \ and 10 is the decimal value of the new-line (\n)). This results in a decimal number that when converted to base 256 with P results in the output |\\n where \n is the literal new-line character. A duplicate of this decimal number is also stored on top of register a.
Then, a "macro-loop" is invoked, as long as n > 1, in which a counter is incremented until n, beginning from 2, and, as the 3rd through nth base 256 digits are unset, 256 is raised to each of those increments, a result which is then multiplied by 32 (the ASCII single space character). Then the value on top of register a is incremented by the resulting product, thus, on each iteration, setting each one of the unset base 256 digits in the between the | and the \ characters to a single space.
Finally, after all n-1 lines have been output, another "macro-loop" is invoked in which all the n+1 dashes are output through the feeding of 45 to P on each iteration.
Note: The [q]st1=t segment makes sure that nothing is output for the input 0 by checking if the incremented input is equal to one, and if it is, simply executes the macro [q] which exits the program.

C 101 93 75 bytes
f(n){i;for(i=0;i++<n;)printf("|%*c\n",i,92);for(;n--+1;)printf("-");}

Ungolfed version
void f(int n)
{
  int i;

  for(i=0;i++<n;)
    printf("|%*c\n",i,92);

  for(;n--+1;)
    printf("-");

}

@Steadybox Thanks for pointing out, makes a lot of sense.

You can shave off a few bytes by replacing character constants with their ASCII value and moving the first i++ in the loop body. And why is printf("%c",'_'); so verbose?

@Jens stimmt, Danke sehr :) Updated

This can be cut down to 74 bytes: i;f(n){for(i=0;i++<n;)printf("%c%*c\n",124,i,92);for(;n--+1;)printf("-");}

To 69 bytes, actually: i;f(n){for(i=0;i++<n;)printf("|%*c\n",i,92);for(;n--+1;)printf("-");}

@Steadybox 68: n--+1 can be shortened to ~n--

@Steadybox No need for two for loops, I can get it down to 58 bytes but at that point it's a totally different answer so I've posted it here: http://codegolf.stackexchange.com/a/109541/16513

@Steadybox Thanks for pointing out and saving 18 bytes

Common Lisp, 89 86 bytes
Creates an anonymous function that takes the n input and prints the triangle to *standard-output* (stdout, by default).
Golfed
(lambda(n)(when(< 0 n)(dotimes(i n)(format t"|~v@t\\~%"i))(format t"~v,,,'-<~>"(1+ n))))

Ungolfed
(lambda (n)
  (when (< 0 n)
    (dotimes (i n)
      (format t "|~v@t\\~%" i))
    (format t "~v,,,'-<~>" (1+ n))))

I'm sure I could make this shorter somehow.

Retina, 39 bytes
.*
$*
*\`(?<=(.*)).
|$.1$* \¶
1
-
-$
--

Try it online
Convert decimal input to unary. Replace each 1 with |<N-1 spaces>\¶, print, and undo replace. Replace each 1 with a hyphen, and the last hyphen with 2 hyphens. Tadaa!

SmileBASIC, 51 bytes
INPUT N
FOR I=0TO N-1?"|";" "*I;"\
NEXT?"-"*(N+!!N)

Charcoal, 15 bytes
Ｎβ¿β«↓β→⁺¹β↖↖β»

Try it online!
Breakdown
Ｎβ¿β«↓β→⁺¹β↖↖β»
Ｎβ               assign input to variable β
   ¿β«         »  if β != 0:
      ↓β           draw vertical line β bars long
        →⁺¹β       draw horizontal line β+1 dashes long
            ↖      move cursor up one line and left one character
             ↖β    draw diagonal line β slashes long

Very late comment, but the closing » can be omitted.

Japt, 20 bytes
Saved 2 bytes thanks to @ETHproductions
o@'|+SpX +'\Ãp-pUÄ)·

Try it online!
Explanation
o@'|+SpX +'\Ãp-pUÄ)·
o                       // Creates a range from 0 to input
 @                      // Iterate through the array
  '|+                   // "|" +
     SpX +              // S (" ") repeated X (index) times +
          '\Ã            // "\" }
             p-pU       // "-" repeated U (input) +1 times
                 Ä)·    // Join with newlines

Nice one! You can save a byte by pushing the last row before joining: o@'|+SpX +'\Ãp'-pUÄ)· and due to a bug (really an unintentional side effect of auto-functions), you can then remove the ' in '-.

Actually, it's like that with all lowercase letters, not just p. That's so you can do e.g. m*2 to double each element, or mp2 to square each

J, 20 bytes
-13 bytes thanks to bob
*#' \|-'{~3,~2,.=@i.

Try it online!
original: 33 bytes
(#&'| \'@(1,1,~])"0 i.),('-'#~>:)

ungolfed
(#&'| \' @ (1,1,~])"0 i.) , ('-'#~>:)

Try it online!

25 bytes with *,&'-' '|',.'\'{."0~_1-i.

22 bytes with *,&'-' '|',.' \'{~=@i.

@bob That was very clever to use identity matrix

@bob thanks for the suggestion.  i've updated the post

Commodore BASIC (C64/128, TheC64 & Mini, VIC-20, PET, C16/+4) - 46 BASIC Bytes
0inputn:ifnthenfori=1ton:?"{shift+B}{left}"spc(i)"{shift+M}":next:fori=.ton:print"-";:next

There is a sanity check for zero, but any other positive integer will work.
Note, a C64 has 25 rows and 40 columns text (some PETs and the C128 in VDC mode has 80 columns, the VIC-20 is 22 columns by 23 rows) so the output will be skewed if you exceed the screen limit in either direction.
I've added a screenshot so that you may see the PETSCII characters that I can't make happen in this listing.

Python 2, 67 bytes
Another function in Python 2, using rjust.
lambda n:('|'.join(map('\\\n'.rjust,range(n+2)))+'-'*-~n)[4:]*(n>0)

Try it online!

Perl, 63 bytes
$n=shift;print'|',$"x--$_,"\\\n"for 1..$n;print'-'x++$n,$/if$n

Ungolfed:
$ perl -MO=Deparse triangle.pl
$n = shift @ARGV;
print '|', $" x --$_, "\\\n" foreach (1 .. $n);
print '-' x ++$n, $/ if $n;

$" is the list separator, which defaults to " ".  $/ is the output record separator, which defaults to "\n".  $_ is the implicit loop variable.

probably could save some by reading the input off of stdin?$n=<>?

bash + Unix utilities, 71 bytes
(($1))&&(echo '|\';(($1-1))&&$0 $[$1-1]|sed 's/|/| /;s/-/--/'||echo --)

Test program:
for n in 0 1 2 3 4 5; do echo $n; ./triangle $n; echo; done

Test output:
0

1
|\
--

2
|\
| \
---

3
|\
| \
|  \
----

4
|\
| \
|  \
|   \
-----

5
|\
| \
|  \
|   \
|    \
------

MATL, 19 bytes
?'\|- '2GXyYc!3Yc!)

Try it online!
?         % Implicit input. If non-zero
  '\|- '  %   Push this string
  2       %   Push 2
  G       %   Push input
  Xy      %   Identity matrix of that size
  Yc      %   Prepend a column of 2's to that matrix
  !       %   Transpose
  3       %   Push 3
  Yc      %   Postpend a column of 3's to the matrix
  !       %   Transpose
  )       %   Index into string
          % Implicit end. Implicit display

Python2, 73 bytes
n=input()
w=0
exec'print"|"+" "*w+"\\\\"+("\\n"+"-"*-~n)*(w>n-2);w+=1;'*n

A full program. I also tried string interpolation for the last line, but it turned out be a couple bytes longer :/
exec'print"|%s\\\\%s"%(" "*w,("\\n"+"-"*-~n)*(w>n-2));w+=1;'*n

Another solution at 73 bytes:
n=j=input()
exec'print"|"+" "*(n-j)+"\\\\"+("\\n"+"-"*-~n)*(j<2);j-=1;'*n

Test cases
0:

1:
|\
--

2:
|\
| \
---

3:
|\
| \
|  \
----

6:
|\
| \
|  \
|   \
|    \
|     \
-------

I apologise for my previous comment, functions are now allowed.

@Okx No problem. This stands as a full program. I don't think I'll look into the fashion of a function solution :)

Pyth, 23 18 bytes
VQ++\|*dN\\)IQ*\-h

Test suite available online.
Thanks to Ven for golfing off 5 bytes.
Explanation
VQ++\|*dN\\)IQ*\-h
 Q           Q    Q  [Q is implicitly appended, initializes to eval(input)]
       d             [d initializes to ' ' (space)]
VQ         )         For N in range(0, eval(input)):
      *dN             Repeat space N times
   +\|                Prepend |
  +      \\           Append \
                      Implicitly print on new line
            IQ       If (input): [0 is falsy, all other valid inputs are truthy]
                 hQ   Increment input by 1
              *\-     Repeat - that many times
                      Implicitly print on new line

R, 101 bytes
for(i in 1:(n=scan())){stopifnot(n>0);cat("|",rep(" ",i-1),"\\\n",sep="")};cat("-",rep("-",n),sep="")

This code complies with the n=0 test-case if you only consider STDOUT !
Indeed, the stopifnot(n>0) part stops the script execution, displays nothing to STDOUT but writes Error: n > 0 is not TRUE to SDTERR.
Ungolfed :
for(i in 1:(n=scan()))
    {
    stopifnot(n>0)
    cat("|", rep(" ", i-1), "\\\n", sep = "")
    }

cat("-", rep("-", n), sep = "")

Might want to fix the spelling of ungolfed

Befunge-98, 68 bytes
&:!#@_000pv<
:kg00 ',|'<|`g00:p00+1g00,a,\'$,kg00
00:k+1g00-'<@,k+1g

This looks like a very nice first answer, but when I try it online, I get the wrong results. Any idea what's wrong there?

@DJMcMayhem I checked it, the TIO gives k instruction one more execution (executes pop()+1 times). Bug in their implementation.

@UrielEli which interpreter are you using? According to a github issue there is one weird (cfunge) that does this,like you, but all the others, including TIO work as intended (see here https://github.com/catseye/FBBI/issues/1#issuecomment-272643932)

Python 2, 62 bytes
n=input();s='\\'
exec"print'|'+s;s=' '+s;"*n
if n:print'-'*-~n

Try it online!
Prints line by line, each time adding another space before the backslash. If a function that doesn't print would be allowed, that would likely be shorter.

Apparently, functions do not have to print.

JavaScript (ES6), 71 bytes

f=
n=>console.log(' '.repeat(n).replace(/./g,'|$`\\\n')+'-'.repeat(n+!!n))
<form onsubmit=f(+i.value);return!true><input id=i type=number><input type=submit value=Go!>

Outputs to the console. Save 6 bytes if printing to the SpiderMonkey JavaScript shell is acceptable. Save 13 bytes if returning the output is acceptable.

That regex is ingenious. I first tried something along those lines. I din't know about the `$`` pattern, but don't know if I still would've thought of it. Nice.

Haskell, 82 65 bytes
g 0=""
g n=((take n$iterate(' ':)"\\\n")>>=('|':))++([0..n]>>"-")

Try it online! Usage:
Prelude> g 4
"|\\\n| \\\n|  \\\n|   \\\n-----"

Or more nicely:
Prelude> putStr $ g 4
|\
| \
|  \
|   \
-----

QBIC, 41 bytes
:~a>0|[a|?@|`+space$(b-1)+@\`][a+1|Z=Z+@-

Explanation
:~a>0|  Gets a, and checks if a > 0
        If it isn't the program quits without printing anything
[a|     For b=1; b <= a; b++
?@|`+   Print "|"
space$  and a number of spaces
(b-1)   euqal to our current 1-based line - 1
+@\`    and a "\"
]       NEXT
[a+1|   FOR c=1; c <= a+1; c++
Z=Z+@-  Add a dash to Z$
        Z$ gets printed implicitly at the end of the program, if it holds anything
        The last string literal, IF and second FOR loop are closed implicitly.

Pyke, 18 17 bytes
I Fd*\|R\\s)Qh\-*

Try it here!

brainf**k, 256 bytes
[-]>[-]+[[-]>[-],[+[-----------[>[-]++++++[<------>-]<--<<[->>++++++++++<<]>>[-<<+>>]<+>]]]<]<>++++++++++[>+>+++>++++>+++++++++>++++++++++++<<<<<-]>>++>+++++>++>++++<<<<<<[>[-]+>>>>>.>[>+<<<<<.>>>>-]>[-<+>]<<<.>>+<<<<<.<<-]>>>>>>>[<<<.>>>-]<<<<<<[>>>.<<<-]

Try it online!
How it works
# Read input and convert to number (https://esolangs.org/wiki/Brainfuck_algorithms#Input_a_decimal_number)
[-]>[-]+[[-]>[-],[+[-----------[>[-]++++++[<------>-]<--<<[->>++++++++++<<]>>[-<<+>>]<+>]]]<]<

# We need the characters {LF} (10); {space} (32); {minus} (45); \(92) | (120)

P1 > ++++++++++
   [
p0  <
P1  >
P2  >  +
P3  >  +++
P4  >  ++++
P5  >  +++++++++
P6  >  ++++++++++++
P5  <
P4  <
P3  <
P2  <
P1  < -
   ]
P0 <           # Contains n
P1 >           # is zero
P2 >           # is {LF}
P3 > ++        # is {space}
P4 > +++++     # is {minus}
P5 > ++        # is \
P6 > ++++      # is |
p5 <
p4 <
p3 <
p2 <
p1 <
p0 <
   [           # Loop through n
P1 >[-]+       # p1 will be 1 if input was not 0; used to output the additional {minus}
p2 >
p3 >
p4 >
p5 >
p6 > .
## output p7 spaces; copy p7 to p8
p7 >
   [
p8 > +
p7 <
p6 <
p5 <
p4 <
p3 < .  # output {space}
p4 >
p5 >
p6 >
p7 > -
   ]
## copy p8 back to p7
p8 >
   [
   -
p7 < +
p8 >
   ]
p7 <
p6 <
p5 < . # output \
p6 >
p7 > + # increase number of spaces
p6 <
p5 <
p4 <
p3 <
p2 < . # output {LF}
p1 <
p0 < -
   ]
p1 >
p2 >
p3 >
p4 >
p5 >
p6 >
## output p7 minuses
p7 >
   [
p6 <
p5 <
p4 < .
p5 >
p6 >
p7 > -
   ]
p6 <
p5 <
p4 <
p3 <
p2 <
## output additional minus
p1 <
  [
p2 >
p3 >
p4 > .
p3 <
p2 <
p1 < -
  ]

This is my first contribution and I'm not sure whether it is allowed to re-use code from others. My code above uses the code published in the Wiki to read the input characters and convert them into a number. Hope that's okay.

Welcome to the site! It is ok to use code that is freely available here.  However I will say that we do usually allow brainfuck to take input by character code.  It does depend on the challenge a bit, because character codes are usually limited to 255, but with the right interpreter or compiler this bound is often optional.

Python 3, 72 71 bytes
x=int(input())
for i in range(x):print('|'+' '*i+'\\')
print('-'*(x+1))

Try it online!
Python 2, 62 bytes
x=input()
for i in range(x):print'|'+' '*i+'\\'
print'-'*(x+1)

Try it online!

Welcome to Code Golf! You can remove three of your spaces to save 3 bytes.

@Stephen, thanks! One question since im new, how do you cross out the previous score in the title?

You can use a  tag, so like <s>72</s>.

You can actually remove all the spaces so that the for loop is on one line. Additionally, the last line of dashes should be one longer

C, 115 112 bytes
i,n,w;f(){if(n){for(i=n;i--;){w=n-i;printf("|");for(;0<--w;)printf(" ");puts("\\");}for(i=n;~i--;)printf("-");}}

Try it online!
x86-32 machine code, 87 bytes
bd00 8089 ecbb 0400 83fb 0074 fe89 d989
d829 c850 b40e b07c cd10 5851 89c1 4183
f901 7502 7408 50b4 0eb0 20cd 1058 90e2
ee50 b40e b05c cd10 5850 b40e b00a cd10
b00d cd10 5859 e2c7 89d9 4150 b40e b02d
cd10 58e2 f6eb fe

To boot, pad it to 510 bytes with zeros and add 55aa at the end!
This means "add times 510 - ($-$$) db 0 and db 0xaa55 to the ungolfed assembly code".
Ungolfed (compilable, compile using nasm -fbin -o triangles triangles.asm):
[org 0x7c00]
[bits 16]

    mov bp, 8000h ; set up stack
    mov sp, bp

    mov bx, 4 ; N

    ; cx = i, bx = n, ax = w
    cmp bx, 0 ; if n == 0, don't print anything
    je $
    mov cx, bx ; i = n
    l1: ; first for
        mov ax, bx
        sub ax, cx ; w = n - i
        push ax
        mov ah, 0eh
        mov al, '|'
        int 10h ; print |
        pop ax
        push cx
        mov cx, ax
        inc cx
        l2: ; second for (prints whitespaces)
            cmp cx, 1 ; if (i != 1) print " "; - there was a bug with first \ printing far right from the triangle
            jne l2_1
            je l2_2
            l2_1:
                push ax
                mov ah, 0eh
                mov al, ' '
                int 10h
                pop ax
            l2_2:
                nop
        loop l2 ; while i < 0 l2(); i--;
        push ax
        mov ah, 0eh
        mov al, '\'
        int 10h ; print backslash
        pop ax
        push ax
        mov ah, 0eh
        mov al, 0ah
        int 10h
        mov al, 0dh
        int 10h ; print newline
        pop ax
        pop cx
    loop l1 ; while i < 0 l1(); i--;
    mov cx, bx ; i = n
    inc cx ; i++
    l3: ; third for (prints dashes)
        push ax
        mov ah, 0eh
        mov al, '-'
        int 10h
        pop ax
    loop l3 ; while i < 0 l3(); i--;

    jmp $ ; hang forever
```

APL (Dyalog Unicode), 41 33 bytes
{×⍵:↑({'\',⍨⍵↑'|'}¨⍳⍵),⊂'-'⍴⍨⍵+1}

Try it online!
-7 bytes from Adám.
-1 byte using signum function.
Explanation
{×⍵:↑({'\',⍨⍵↑'|'}¨⍳⍵),⊂'-'⍴⍨⍵+1} ⍝ ⍵=n
 ×⍵:                              ⍝ If sign(n)
                        '-'⍴⍨⍵+1  ⍝ Repeat '-' n+1 times
                       ⊂          ⍝ Enclose it to a single string
                      ,           ⍝ Join with
                 }¨⍳⍵             ⍝ for each x in range 1..n
            ⍵↑'|'                 ⍝ Inner fn: take x characters from '|' appending spaces
      '\',⍨                       ⍝ Reverse join with '\'

Try it online!

34

@Adám leaving it unmixed gives an interesting pattern.

Pip -n, 21 bytes
IaO['|.sX,a.'\'-Xa+1]

Try it online!
Explanation
IaO['|.sX,a.'\'-Xa+1]
                       s is space; a is 1st command-line arg (implicit)
Ia                     If a is nonzero:
  O                     Output this expression without a trailing newline:
   [                ]    A list containing these two items:
       sX,a               A list of increasing runs of spaces
    '|.                    with a pipe character concatenated to the front of each run
           .'\             and a slash concatenated to the back
              '-Xa+1      A string of a+1 hyphens

For example: with an input of 3, the list will be [["|\"; "| \"; "|  \"]; "----"]. The -n flag separates all items of a list with newlines when it is printed, so we get
|\
| \
|  \
----

The if statement means the program does nothing if the input a is 0, as required.

Vyxal Ṁosr, 12 bytes
⟑I‛|\j…;tƛ\-

Try it Online!
Flags FTW
⟑I‛|\j…;tƛ\-
⟑             # Over each in [0, n) (not [1, n] thanks to Ṁ flag)
 I            # Push n spaces
  ‛|\j        # Join ['|', '\'] by that (r flag makes the arguments reversed)
      …       # Print it with a trailing newline (without popping)
       ;      # Close loop
        t     # Get the last element
         ƛ\-  # Replace each with a hyphen
              # o flag - force implicit output
              # s flag - join this list of hyphens to a single string

Javascript 101(Full Program), 94(Function Output), 79(Return) bytes
Full Program
Will not run in Chrome (as process doesn't exist apparently)
Will not run in TIO (as prompt apparently isn't allowed)
x=prompt();s='';for(i=0;i<x;i++)s+='|'+' '.repeat(i)+`\\
`;process.stdout.write(s+'-'.repeat(x&&x+1))

Function with EXACT print
x=>{s='';for(i=0;i<x;)s+='|'+' '.repeat(i++)+`\\
`;process.stdout.write(s+'-'.repeat(x&&x+1))}

Try it Online
Function with return string
x=>{s='';for(i=0;i<x;)s+='|'+' '.repeat(i++)+`\\
`;return s+'-'.repeat(x&&x+1)}

Try it Online
Repeating characters in Javascript is dumb and so is suppressing newlines on output

Python 2, 82 bytes
def f(i,c=0):
 if c<i:print'|'+' '*c+'\\';f(i,c+1)
 print'-'*((c+1,c)[c<1]);exit()

Try it online!
Longer that the other Python answers but a recursive function just to be different.
It feels wasteful using two print statements but I can't find a shorter way round it. Also the exit() wastes 7 to stop it printing decreasing number of - under the triangle.

You can do -~c*(c>0) on the last line to save 3 bytes :)

Or better yet: c and-~c.

Javascript (ES6), 84 bytes
Creates an anonymous function that presents the result on an alert box. No output is present if 0.
i=>{for(X=i,a='';i--;)a='|'+(' '.repeat(i))+'\\\n'+a;X&&alert(a+('-'.repeat(++X)))}

If printing is really required (137 bytes):
i=>for(X=i,d=document.body;i--;)d.innerHTML='|'+(' '.repeat(i))+'\\
'+d.innerHTML;X&&window.print(d.innerHTML+=('-'.repeat(++X)))

Changes the HTML code and prints the page into a paper sheet.
The page stays white if 0.

@LliwTelracs Should work now. If it is required to show the alert when it is 0, I can do it without increasing the size again.

Clojure, 104 bytes
(fn[h](let[r #(apply str(repeat % %2))](doseq[n(range h)](println(str\|(r n\ )\\)))(print(r(inc h)\-))))

At least I should have lots of room to golf from here!
Loops over the range from 0 to h-1, printing a \|, then h-many spaces, then a \\. Finally, at the end, it prints h+1 many dashes.
(defn triangle [hypot-n]
  (let [r #(apply str (repeat % %2))] ; Create a shortcut string repeat function, since I need it twice.
    (doseq [line-n (range hypot-n)] ; Loop over the range 0 to hypot...
      (println (str \| (r line-n \ ) \\))) ; Printing a bar, then line-n many spaces, then a slash
    (print (r (inc hypot-n) \-)))) ; Then print the trailing dashes

Batch, 110 bytes
@set s=
@for /l %%i in (1,1,%1)do @call:c
@if %1 gtr 0 echo -%s: =-%
@exit/b
:c
@echo ^|%s%\
@set s= %s%

Special-casing 0 is no hardship as %s: =-% would fail anyway.

JavaScript, 66 bytes
f=(x,i=0)=>i<x?`|${" ".repeat(i)}\\\n`+f(x,i+1):"-".repeat(x&&i+1)

Mathematica, 57 bytes
Array[{"|"," "~Table~#,"\\
"}&,#,0]<>Table["-",#+Sign@#]&

Unnamed function taking a nonnegative integer as input and returning a string-with-newlines. It deals with the special case of input 0 by noting that the number of dashes is equal to the input plus the sign of the input.

Underload, 58 39 bytes
:()~(|)~(~!((-):S~^S)~:S( )*(\
)S)~^^!^

Assumes the input is a Church numeral on the stack.
Explanation
          stack (assume input N = 2):
            (:*)
:         keep a copy of the input on the bottom
            (:*)(:*)
()~       insert the finalization snippet
            (:*)()(:*)
(|)~      insert the accumulator
            (:*)()(|)(:*)
(...)~^^  run (...) N times:

    ~!(...)~  set finalization snippet
                (:*)((-):S~^S)(|)
    :S        output copy of accumulator
                (:*)((-):S~^S)(|)           output = |
    ( )*      append space to accumulator
                (:*)((-):S~^S)(| )          output = |
    (\;)S     output backslash and newline
               (:*)((-):S~^S)(| )          output = |\;

    ~!(...)~  set finalization snippet
                (:*)((-):S~^S)(| )
    :S        output copy of accumulator
                (:*)((-):S~^S)(| )          output = |\;|
    ( )*      append space to accumulator
                (:*)((-):S~^S)(|  )         output = |\;|
    (\;)S     output backslash and newline
                (:*)((-):S~^S)(|  )         output = |\;| \;

!         delete accumulator
            (:*)((-):S~^S)                  output = |\;| \;
^         execute finalization snippet:
            (:*)                            output = |\;| \;

    (-)       push hyphen
                (:*)(-)                     output = |\;| \;
    :S        output hyphen
                (:*)(-)                     output = |\;| \;-
    ~^        repeat N times
                (--)                        output = |\;| \;-
    S         print
                                            output = |\;| \;---

8th, 94 89 bytes
Code
: f 0; dup ( "|" . ( " " . ) swap times "\\" . cr ) 0 rot n:1- loop n:1+ "-" swap s:* . ;

Explanation
The word f requires an integer input
: f \ n --
   0;                      \ Exit if input equals to 0
   dup                     \ Duplicate input on the stack
   ( "|" .                 \ Print a piece of the vertical side
   ( " " . ) swap times    \ Print space between sides
   "\\" . cr )             \ Print a piece of the slanted side
   0 rot n:1- loop         \ Repeat the above operation for the size required
   n:1+ "-" swap s:* .     \ Print the bottom side
;

Usage
ok> 4 f
|\
| \
|  \
|   \
-----

Ruby, 48 bytes
->n{puts ?-*(n.times{|x|puts ?|+' '*x+?\\}+(n<=>0))}

Jelly, 19 bytes
Ḷ×⁶j@€⁾|\;‘×”-$$YxṠ

Try it online!
Explanation:
Ḷ×⁶j@€⁾|\;‘×”-$$YxṠ Link 0. Arguments: z.
Ḷ                   Range from 0 to z - 1. [arg-z]
  ⁶                 Space (' ').
 ×                  Product of x and y. [multi-char-string-warning]
      ⁾|\           Two char string ("|\").
   j                Join x on y.
    @               Reverse arguments.
     €              Convert this link to a map on the left argument.
          ‘         Increment z. [arg-z]
            ”-      Character ('-').
           ×        Product of x and y. [multi-char-string-warning]
              $     Merge last two links to a monadic link.
               $    Merge last two links to a monadic link.
         ;          Concatenate x and y.
                Y   Join z on newlines ('\n').
                  Ṡ Sign of z. [arg-z]
                 x  Repeat x y times.

PHP, 75 bytes
(70 bytes if I used extended ascii)
for($p=str_pad;+$i<$argv[1];)echo$p("|",++$i),"\\
";echo$p("",$i+!!$i,"-");

takes input from command line argument. Run with -nr.

Swift 3 96 bytes
var a=5,b="";for c in 0..<a{var d="|";for _ in 0..<c{d+=" "};print(d+"\\");b+="-"};print(b+"-")

Can you do var a=5,b=""; in Swift?

Yes its possible

Also can't you do print(b+"-") instead of b+="-";print(b)?

I guess now its perfect

Also var a=5,b="",d;for c in 0..<a{d="|" instead of the beginning of the loop if it works

No that will increase 1 byte as the code will become  var a=5,b="",d="";for c in 0..<a{d="|";for _ in 0..<c{d+=" "};print(d+"\");b+="-"};print(b+"-")

In Swift either you need to initialize a variable with any value or with the type. So it's better to initialize with the value

Ah sorry, I don't know Swift

And by the way, welcome to PPCG!

Python 3, 75 bytes
def x(n):
 if n:
  for i in range(n):print('|'+' '*i+'\\')
  print('-'*-~n)

Try it online!
Here's my Python 3 answer, and it's pretty long. I wonder how I can shorten it...
Thanks to Eric The Outgolfer for helping in the comments...

VBA Excel, 68 65 bytes
Using Immediate Window and [a1] as input
for x=0to[a1]-1:?"|"string(x,32)"\":next:if x then?string(x+1,45)

You can drop this down to 65 bytes For i=0To[A1-1]:?"|"String(i,32)"\":Next:If i Then?String(i+1,45)

Python 3, 61 bytes
n=5
q="".join(map(lambda x:"|%s\\\n"%(x*" "),range(n)))+"-"*n

Try it online!

Perl 5, 50 +2 (-ap) = 52 bytes
$_&&='|\\';say,s/\\/ $&/ while$F[0]--;s/./-/g;chop

Try it online!

Acc!!, 179 bytes
N
Count d while _%60-10 {
(_/60*10+_%60-48)*60+N
}
_/60
Count r while _-r {
Write 124
Count s while r-s {
Write 32
}
Write 92
Write 10
}
Count h while _+3*_/(3*_-1)-h {
Write 45
}

Try it online!
Explanation
Load a number into the accumulator, print that many rows of | ... \, and print that many (plus 1) hyphens. Unless the number is 0, in which case print 0 hyphens. No trailing newline in any case.
Most of the code is quite straightforward (handy loop variable mnemonics: digit, row, space, and hyphen). The two interesting parts are inputting a multi-digit number and handling the 0 case.
Inputting a number
N
Count d while _%60-10 {
(_/60*10+_%60-48)*60+N
}
_/60

We divide the accumulator into two sections: _%60 stores the ASCII code of the character we just read, and _/60 stores the number we're constructing. We loop until _%60 is 10--that is, when we encounter a newline. Inside the loop, _%60 is the ASCII code of the new least-significant digit. _%60-48 is the digit itself. _/60 is the previous value of the number, so we multiply that by 10 and add the new digit to get the new value of the number: _/60*10+_%60-48. Multiply that quantity by 60 and add the next input character N, and we're ready to loop. After the loop finishes, we set the accumulator to _/60, the stored number itself.
Handling the 0 case
Count h while _+3*_/(3*_-1)-h {

My original loop condition was _+1-h: loop (accumulator + 1) times. But if the accumulator is 0, we want to loop 0 times, not 1. So instead of adding 1, we add 3*_/(3*_-1). When _ is 0, this quantity is 0. When _ is greater than 0, this quantity is 1 (since 3*_ is less than twice 3*_-1).

Java 8, 109 bytes
n->{String r="|\\\n";int i=0;for(;++i<n;r+=r.format("|%"+i+"s\\%n",""));for(;i-->=0;r+="-");return n<1?"":r;}

Can most likely be golfed some more.
Explanation:
Try it here.
n->{                 // Method with integer parameter and String return-type
  String r="|\\\n";  //  Result-string, starting at "|\" + new-line
  int i=0;           //  Index-integer, starting at 0
  for(;++i<n;        //  Loop (1) from 1 to `n` (exclusive)
    r+=              //   Append to the result-String:
       r.format("|   //    A literal "|"
        %"+i+"s      //    + `i` amount of spaces
        \\           //    + a literal "\"
        %n","")      //    + a new-line
  );                 //  End of loop (1)
  for(;i-->=0;       //  Loop (2) from `n` down to 0 (inclusive)
    r+="-"           //   Append that many literal "-" to the result-String
  );                 //  End of loop (2)
  return n<1?        //  If the input was 0:
    ""               //   Return an empty String
   :                 //  Else:
    r;               //   Return the result-String
}                    // End of method

SNOBOL4 (CSNOBOL4), 98 bytes
	N =INPUT
T	OUTPUT =LT(X,N) '|' DUPL(' ',X) '\'	:F(E)
	X =X + 1	:(T)
E	OUTPUT =DUPL('-',X + 1)
END

Try it online!

Japt -R, 14 bytes
°Æ'\i|úXÄÃpUç-

Try it
°Æ'\i|úXÄÃpUç-     :Implicit input of integer U
°                  :Postfix increment U
 Æ                 :Map each X in the range [0,U)
  '\               :  Literal "\"
    i              :  Prepend
     |ú            :    "|" right padded with spaces to length
       XÄ          :   X+1
         Ã         :End map
          p        :Push
           Uç-     :  "-" repeated U (now incremented) times
                   :Implicit output, joined with newlines

JavaScript (Babel Node), 65 bytes
f=(n,s=`\\
`,l)=>n?'|'+s+f(n-1,' '+s,l||'-'.repeat(n&&n+1)):l||''

Try it online!

Hello and welcome to PPCG; nice first answer.

Haxe 4 (161 bytes)
class T{static function main()trace((x->x==0?"":[for(i in 0...x+1)i==x?[for(i in 0...x+2)""].join("-"):"|"+[for(i in -1...i)""].join(" ")+"\\"].join("\n"))(3));}

Try Online (slightly bigger there since playground requires class to be called "Test")
Test
Save as T.hx, compile and run interpreted mode haxe --run T
How it works
class T {
    static function main()
        trace(
            (x ->
                x == 0
                        ? ""
                        : [for (i in 0...x + 1)
                                i == x
                                        ? [for (i in 0...x + 2) ""].join("-")
                                        : "|" + [for (i in -1...i) ""].join(" ") + "\\"
                ].join("\n")
            )(3)
        );
}

A class and entrypoint (static function called main) are required in Haxe.
(3) is the input
The snippet compiles to of all Haxe compiler targets (C++, JavaScript, PHP, Python, Lua, JVM, Java, etc)

05AB1E, 15 bytes
F'|NúR'\J,}ƒ'-?

Try it online!

Zsh, 60 bytes
for ((;i<$1;))printf "|%$[i++]s\\\\\n"&&a=$a-
(($1))&&<<<$a-

Try it Online. Credit to the bash solution.

><>, 86 bytes
:?!;01.
!0:@>"|"o>:?va"\"oo~:&$1+:&(?!v
   "-"v>-^ ;8>1-:?!;53!.|     >
 o"-"o<^1o*4<^

Try it online! - Animated
Good luck figuring this out

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Anagram Factors
On a recent episode of QI, the first 5 multiples of 142857 were described as anagrams of the original number. Of course, anyone with more than a passing knowledge of that number will know that those numbers are actually cyclic, not just anagrams. But that got me thinking.
Please write a program or function that outputs all numbers of six or fewer digits which have a proper factor that is an anagram of itself. The list should start with the following numbers:
3105    (divisible by 1035)
7128    (divisible by 1782)
7425    (divisible by 2475)
8316    (divisible by 1386)
8712    (divisible by 2178)
9513    (divisible by 1359)
9801    (divisible by 1089)

If you prefer, you can find numbers which have an anagram that is a proper factor of the number, but take care to exclude leading zeros from your anagrams.
This is code golf, so the shortest code in bytes that breaks no standard loopholes wins.

If given enough time, can our programs output numbers with more than 6 digits?

Could you please post the list?

@muddyfish Yes, that would be acceptable, as long as it doesn't omit any numbers or output incorrect numbers as it goes.

@xnor I haven't actually bothered calculating the whole list yet, although I'm not expecting any disputes over it.

Must the output be sorted? Must each number appear once?

I made a pastebin of my (hopefully correct) output.

@xnor Yes to both.

9513 is missing from your starting list.

Mathematica (REPL environment), 75 74 bytes
Thanks to ngenisis for tightening this up by a byte!
Select[Range[10!],Most@#~MemberQ~Last@#&[Sort/@IntegerDigits@Divisors@#]&]

Sort/@IntegerDigits@Divisors@# produces a sorted list of digits for every divisor of its argument; the input number is itself a divisor, so its sorted list of digits is the last one. Most@#~MemberQ~Last detects whether that last sorted list of digits also appears in the list prior to the last element. And Select[Range[10!],...] retains only those integers up to 3,628,800 that pass this test (that bound chosen because it's one byte shorter than 106). It runs in about 5 minutes on my computer, yielding a list of 494 numbers, the largest of which is 3,427,191; there are 362 numbers up to 106, the larget of which is 989,901.

Well, it's not that curious: 857142 and 571428 are two numbers both with two obvious proper divisor anagrams.

In fact, 857142 has three proper divisor anagrams, does it not?

looks like you're right!

You can save a byte by using IntegerDigits@Divisors@#.

JavaScript (ES6), 103 … 96 94 bytes
An anonymous function that returns the array of matching integers.
_=>[...Array(1e6).keys(F=i=>[...i+''].sort()+0)].filter(n=>n*(R=i=>F(n/i--)==F(n)||R(i)%i)(9))

Formatted and commented
_ =>                                // main function, takes no input
  [...Array(1e6).keys(              // define an array of 1,000,000 entries
    F = i => [...i + ''].sort() + 0 // define F: function used to normalize a string by
  )]                                // sorting its characters
  .filter(n =>                      // for each entry in the array:
    n * (                           // force falsy result for n = 0
      R = i =>                      // define R: recursive function used to test if
        F(n / i--) == F(n) ||       // n/i is an anagram of n, with i in [1 … 9]
        R(i) % i                    // F(n/1) == F(n) is always true, which allows to stop
    )                               // the recursion; but we need '%i' to ignore this result
    (9)                             // start recursion with i = 9
  )                                 //

Divisor statistics
For 6-digit integers, each ratio from 2 to 9 between a matching integer n and its anagram is encountered at least once. But some of them appear just a few times:
 divisor | occurrences | first occurrence
---------+-------------+---------------------
    2    |    12       | 251748 / 2 = 125874
    3    |    118      | 3105   / 3 = 1035
    4    |    120      | 7128   / 4 = 1782
    5    |    4        | 714285 / 5 = 142857
    6    |    34       | 8316   / 6 = 1386
    7    |    49       | 9513   / 7 = 1359
    8    |    2        | 911736 / 8 = 113967
    9    |    23       | 9801   / 9 = 1089

Test
The test below is limited to the range [1 ... 39999] so that it doesn't take too much time to complete.

let f =

_=>[...Array(4e4).keys(F=i=>[...i+''].sort()+0)].filter(n=>n*(R=i=>F(n/i--)==F(n)||R(i)%i)(9))

console.log(f())

Much faster version, but somewhat longer: _=>[...Array(1e6).keys()].filter(n=>n&&![...Array(9)].every(_=>n%++i||(F=i=>[...i+''].sort()+'')(n/i)!=F(n),i=1)).

@Neil Your suggestion inspired me the updated version which is much faster and 1 byte shorter. Sadly, all divisors from 2 to 9 are required (8 being used only twice for 911736 and 931176).

Jelly, 12 bytes
ÆḌṢ€ċṢ
ȷ6ÇÐf

Try it online! (uses five or fewer digits because of TIO's time limit)
Verfication
$ time jelly eun 'ÆḌṢ€ċṢ¶ȷ6ÇÐf'
[3105, 7128, 7425, 8316, 8712, 9513, 9801, 30105, 31050, 37125, 42741, 44172, 67128, 70416, 71208, 71253, 71280, 71328, 71928, 72108, 72441, 74142, 74250, 74628, 74925, 78912, 79128, 80712, 81816, 82755, 83160, 83181, 83916, 84510, 85725, 86712, 87120, 87132, 87192, 87912, 89154, 90321, 90801, 91152, 91203, 93513, 94041, 94143, 95130, 95193, 95613, 95832, 98010, 98091, 98901, 251748, 257148, 285174, 285714, 300105, 301050, 307125, 310284, 310500, 321705, 341172, 342711, 370521, 371142, 371250, 371628, 371925, 372411, 384102, 403515, 405135, 410256, 411372, 411723, 415368, 415380, 415638, 419076, 419580, 420741, 421056, 423711, 425016, 427113, 427410, 427491, 428571, 430515, 431379, 431568, 435105, 436158, 441072, 441720, 449172, 451035, 451305, 458112, 461538, 463158, 471852, 475281, 501624, 502416, 504216, 512208, 512820, 517428, 517482, 517725, 525771, 527175, 561024, 562104, 568971, 571428, 571482, 581124, 589761, 615384, 619584, 620379, 620568, 623079, 625128, 641088, 667128, 670416, 671208, 671280, 671328, 671928, 672108, 678912, 679128, 681072, 691872, 692037, 692307, 704016, 704136, 704160, 704196, 705213, 705321, 706416, 711342, 711423, 712008, 712080, 712503, 712530, 712800, 713208, 713280, 713328, 713748, 714285, 716283, 717948, 719208, 719253, 719280, 719328, 719928, 720108, 720441, 721068, 721080, 721308, 721602, 723411, 724113, 724410, 724491, 728244, 730812, 731892, 732108, 741042, 741285, 741420, 742284, 742500, 744822, 746280, 746928, 749142, 749250, 749628, 749925, 753081, 754188, 755271, 760212, 761082, 761238, 761904, 771525, 772551, 779148, 783111, 786912, 789120, 789132, 789192, 789312, 790416, 791208, 791280, 791328, 791928, 792108, 798912, 799128, 800712, 806712, 807120, 807132, 807192, 807912, 814752, 816816, 818160, 818916, 820512, 822744, 823716, 824472, 825174, 825714, 827550, 827658, 827955, 829467, 830412, 831117, 831600, 831762, 831810, 831831, 839160, 839181, 839916, 840510, 841023, 841104, 843102, 845100, 845910, 847422, 851148, 851220, 851742, 852471, 857142, 857250, 857628, 857925, 862512, 862758, 862947, 865728, 866712, 867120, 867132, 867192, 867912, 871200, 871320, 871332, 871425, 871920, 871932, 871992, 874125, 879120, 879132, 879192, 879912, 888216, 891054, 891540, 891594, 891723, 892755, 894510, 895725, 899154, 900801, 901152, 903021, 903210, 903231, 904041, 908010, 908091, 908901, 909321, 910203, 911043, 911358, 911520, 911736, 911952, 912030, 912093, 912303, 916083, 920241, 920376, 923076, 923580, 925113, 925614, 930321, 931176, 931203, 933513, 934143, 935130, 935193, 935613, 935832, 940410, 940491, 941430, 941493, 941652, 943137, 943173, 951300, 951588, 951930, 951993, 952380, 956130, 956193, 956613, 958032, 958320, 958332, 958392, 958632, 958716, 959832, 960741, 962037, 962307, 970137, 971028, 980100, 980910, 980991, 989010, 989091, 989901]

real    2m10.819s
user    2m10.683s
sys     0m0.192s

How it works
ȷ6ÇÐf   Main link. No arguments.

ȷ6      Yield 1e6 = 1,000,000.
  ÇÐf   Filter; keep numbers in [1, ..., 1e6] for which the helper link returns
        a truthy value.

ÆḌṢ€ċṢ  Helper link. Argument: n

ÆḌ      Compute all proper divisors of n.
  Ṣ€    Sort each proper divisor's digits.
     Ṣ  Sort n's digits.
   ċ    Count the occurrences of the result to the right in the result to the left.

Due to this comment you can do the even slower ÆḌṢ€ċṢµȷ# for 10. Took ~27 mins to run on an i7 core (not on unix, no nice time); the largest result was 6671928.

I'm starting to think you modify Jelly on a per question basis

Brachylog, 12 bytes
ℕf{k∋p.!}?ẉ⊥

Try it online!
This might time out before printing anything though (and if it doesn't it will only get to print 3105).
Explanation
This prints those numbers indefinitely, as the author said it was acceptable that the program would print numbers bigger than 6 digits.
This is way too slow; you can use this program (and change 8300 by any N) to start printing from numbers stricly greater than N.
ℕ               Natural number: The Input is a natural number
 f              Factors: compute the factors of the Input
  {     }?      Call a predicate with the main Input as its output and the factors as Input
   k            Knife: remove the last factor(which is the Input itself)
    ∋           In: take one of those factors
     p.         Permute: the Output is a permutation of that factor
       !        Cut: ignore other possible permutations
         ?ẉ     Writeln: write the Input to STDOUT, followed by a line break
           ⊥    False: backtrack to try another value for the Input

As @ais523 pointed out, we need a cut to avoid printing a number multiple times if several of its factors are permutations of it.

I have a very it similar answer saved as a draft. Unfortunately, I don't think it works because it'll print numbers like 857142 more than once, and the author said that that's disallowed. I think the program needs a cut somewhere, likely adding three characters.

Adding 4 characters in fact... thanks, forgot about that.

Pyke, 14 bytes
~1#`Sili-m`mS{

Try it here!
Should output all numbers like this but times out.
Test the algorithm here!

Perl 6, 59 bytes
{grep {grep .comb.Bag===*.comb.Bag,grep $_%%*,2..^$_}

Terribly slow brute-force solution.
It returns a lazy sequence, so I could check the first few results, but it won't reach all results in reasonable time. (Should I mark it as non-competing?)

Pure Bash, 128 126 122 121 120 bytes
for((;n<6**8;)){
c=0
for((j=++n;j;j/=10)){((c+=8**(j%10)));}
for k in ${a[c]};{((n%k))||{ echo $n;break;};}
a[c]+=\ $n
}

Try it online!
(This program is reasonably fast -- it took only 14 minutes to run through all the 6-digit numbers on my MacBook. Unfortunately TIO times out because it imposes a running-time limit of 1 minute, which is only enough time to get through the 5-digit numbers or so.)
Bash + Unix utilities, 117 bytes
for n in {1..999999}
{
c=$(bc<<<0`sed 's/\(.\)/+8^\1/g'<<<$n`)
for k in ${a[c]};{((n%k))||echo $n;}
a[c]+=\ $n
}|uniq

This is shorter than the pure bash version, but quite a bit slower, presumably due in good part to all the forking going on.

Japt, 23 bytes
L³o f_ì á ¤fg mì f!vZ l

Try it online! Note that the linked code only calculates up to 1e4 because 1e6 times out on TIO.

05AB1E, 12 10 bytes
Times out on TIO due to infinite loop.
Saved 2 bytes as we could output more than 6-digit numbers according to OPs comment.
[NÑ¨€{N{å–

Try it online!
Explanation
[            # infinite loop with iteration index N
 NÑ          # get a list of all divisors of N
   ¨         # remove N from that list
    €{       # sort each entry in the list of divisors
      N{     # sort N
        å–   # output N if N is in the list

05AB1E, 15 bytes
[¼¾œJv¾Ñ¨Dyåi¾,

Explanation:
[               # Start of infinite loop
 ¼              # Increase counter_variable by 1
  ¾œJv          # Loop through all the permutations of counter_variable
      ¾Ñ¨Dyå    # Check if a divisor of counter_variable is a permutation of counter_variable
            i¾, # If so, print counter_variable

Try it online! (this won't work, it will time out)

Batch, 263 bytes
@echo off
set e=exit/b
for /l %%n in (1,1,999999)do call:n %%n
%e%
:n
call:c %1 1 0
for /l %%f in (2,1,9)do call:c %1 %%f %c%&&echo %1&&%e%
%e%
:c
set/ar=%1%%%2,d=%1/%2,c=-%3
if %r% gtr 0 %e%1
:l
set/ac+=1^<^<d%%10*3,d/=10
if %d% gtr 0 goto l
%e%%c%

Slow. As in, takes over a day to finish on my PC. Explanation: the c subroutine divides its first two arguments. If the remainder is zero, it then calculates the hash of the result by calculating the sum of the nth powers of 8 for each digit. This hash function, stolen from the bash answer, only collides on anagrams. (It would work for seven digit numbers but I don't have all fortnight.) The third argument is subtracted, and the subroutine exits with a truthy result if this is zero. The n subroutine calls the c subroutine once to calculate the hash, then eight more times to compare the hash; if it finds a collision, it prints n and exits the subroutine early.

Haskell (Lambdabot), 87 bytes
[x|x<-[1..],any(\y->show x/=y&&head y/='0'&&rem x(read y::Int)==0)$permutations$show x]

Try it online!
This is probably unoptimal, as it's my first Haskell golf

Python 2, 98 bytes
s=sorted;print filter(None,[[x for i in range(x)if s(`x`)==s(`i`)and x%i<1]for x in range(10**6)])

Shouldn't that be 10**6?

I think x%i==0 can just be x%i<1.

Ruby, 96 bytes
->a{a.chars.permutation.map(&:join).reject{|x|/^0+/.match(x)||x==a}.detect{|n|a.to_i%n.to_i==0}}

The permutation function gives a lot of duplicates, so a large part of this is weedng those out.
Try it online!

Scala, 101 bytes
for(x<-LazyList from 9)s"$x".permutations.find{d=>d.head>48&d.toInt!=x&x%d.toInt<1}map(_=>println(x))

Try it in Scastie (For whatever reason, TIO doesn't recognize LazyLists, not even after importing it explicitly)

Scala (with recursion), 104 bytes
def f(x:Int){s"$x".permutations.find{d=>d.head>48&d.toInt!=x&x%d.toInt<1}map(_=>println(x))
f(x+1)}
f(9)

Do NOT try it online!. Try this modified version instead.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Notcalc (Calculate the wrong answer)
Goal:
Given two natural numbers (integers from 0 to infinity), output a number that is not the sum of those numbers, but is a natural number.
Example solutions (TI-Basic):

A+B+1

not(A+B)

Invalid solutions:

A+B-1 (for inputs 0,0, it returns -1, which is not natural)

"ABC" (ABC is not a number)

Notes:

The output must always be a sum of two natural numbers (which is actually just a natural number)

-1, undefined, infinity, NaN and Error messages are not natural numbers. For our purposes, 0 is natural (although not all mathematicians agree).

Maybe we take the numbers as strings and output as a string?

Can the output have leading zeroes?

@Kritixi_Lithos Yes (allowed by default)

I presume overflows need to be taken into account, so the result of 2^32 -1 and 2 should not be negative, right?

@adrianmp Overflows are not necessary

Just a small remark because I like to pay attention to useless details: 0 is not a natural number. If you change the first sentence to "Given two non-negative integers ...", there won't be any useless detail left for me to comment on. :)

@peech This is not true.  0 is considered a natural number under some definitions.  You cannot see it because it has been deleted but there has been an extensive conversation on this matter.

@WheatWizard My apologies. I didn't know about that conversation.

To have none of something is quite natural. Think of it that way. Anyways, if you look at the Wikipedia article, it seems that even though some people still exclude zero, the standards are moving towards including zero. (Programmers start counting at zero, the standard ISO 80000-2 includes zero, set theory uses zero as the empty set, etc). ℕ = {0,1, 2, …}; ℤ+= {1, 2, …}

"Die ganzen Zahlen hat der liebe Gott gemacht, alles andere ist Menschenwerk" ("God made the integers, all else is the work of man."). -Leopold Kronecker .

RProgN, 4 3 1 Byte
Crossed out 4 is still 4 ;(
E

The most simple of solutions, compares if A and B are equal. Pushes true, which RProgN sees as 1, if they are the same, or false aka 0 otherwise.
Test Cases
0+0 = 1
1+0 = 0
0+1 = 0
1+1 = 1

Try it online!

I just went down the rabbit hole with your crossed out link. I rate it 4/4

@RohanJhunjhunwala hold my 4, I'm going in

̶4̶   <-- u+0336 (combining character) may be a better way to do it

PSA: http://codegolf.stackexchange.com/questions/48100/very-simple-triangles/48101#comment113015_48101 Original crossed out thing

@AlbertRenshaw the old PPCG crossed-out-4-a-roo?

Python, 13 bytes
[(0,0)].count

Try it online! Takes input as a tuple.
Using an object method for the function avoids the boilerplate of a lambda.
lambda a,b:a-~b   # 15 bytes

Here, the idea is to map (0,0) to 1 and everything else to 0. Since only 0+0 gives a sum of 0 among natural numbers, that always avoids matching the sum.
If one could output a Boolean here, which I find shady, a byte could be saved as
(0,0).__ge__

This checks if the input tuple is at most (0,0), which is only true for (0,0). In Python, True==1 and False==0. Even more shadily, outputting via exit code and treating that as a Python Boolen would save two bytes:
[(0,0)].pop

If string I/O is allowed and leading zeroes are OK, there's the 8-byte solution
'1'.join

This concatenates a1b, which is always bigger than a+b.

int.__eq__ for 10 bytes

@muddyfish Yeah, I saw suever's answer too, didn't think of using equality. It returns a bool though, which I think is iffy on a challenge that asks for a number output.

IMO if it swims like a number and quacks like a number, it's reasonable to assume it's a number.

Retina, 3 bytes

1

Try it online!
(The first line has a space before the newline. Stack Exchange isn't very good at showing trailing whitespace.)
Input is the numbers in decimal, separated by a space (e.g. 12 34). This program just changes the space to a 1, creating a number too large to be the sum of the input numbers (it necessarily has at least 2 more digits than either, and adding two numbers produces an output with no more than 1 digit more than the larger input).

0 0 should also work.

@Dennis: I was wondering about that. 010 is considered to be an integer via basically all integer parsers. I can see a potential argument that 0 8 is invalid on the basis that 018 is considered invalid octal via some integer parsers (although it's considered to be decimal 18 by others). Note that this program is quite happy to handle leading zeroes in the input, treating them as decimal; and I've written programs that output leading zeroes for other questions without people seeing a problem. Is there a relevant meta post on the subject?

Or . 1 if you don't want to return leading zeros yourself.

@MartinEnder > but is a natural number

@wizzwizz4 I'm not following.

MATL, et al. 1 byte
=

Accepts two natural numbers as inputs and compares them. If they are equal, the output is 1 and if they not equal the output is 0. This is the same approach as @ATaco's solution.

MATL

Jelly (by @ais523)

Stacked (by @Conor O'Brien)

APL (Dyalog APL) (by @Adám)

J (by @Adám)

Actually (by @Mego)

Implicit (by @MD XF)

W (by @a'_')

Keg (by @a'_')

GolfScript (by @Pseudo Nym)

Vyxal (by @emanresu A)

The = solution also works in Jelly for 1 byte. I thought I'd mention it in the comments as it doesn't seem worth creating a separate answer for the trivial solution.

@ais523 Updated to include that. Thanks.

Also in Stacked. Try it online!

Can you add APL and J?

@Adám Sure thing. Do you have a TIO link that I can link to?

@Suever https://tio.run/nexus/apl-dyalog#@///f9qjtgm2XCYKaQrGAA and  https://tio.run/nexus/j#@///f5qCrZ6CLZeJQpqCMQA

I think this post should be a community wiki instead

@KritixiLithos Thanks. I meant to do that yesterday but got distracted. Updated now so that others can easily edit.

Javascript, 10 bytes
x=>y=>!x+y

Takes 2 numbers using currying syntax like so:
(x=>y=>!x+y)(0)(0) // 1

Welcome to the site! :)

Thanks =) I've been reading challenges for a while, just trying to find a good place to start.

Brain-Flak, 8 bytes
({}{}())

Try it online!
This is the most readable brain-flak answer I have ever written. :)
Explanation:
(      )    # Push the sum of all the following:
 {}         #   The first input
   {}       #   The second input
     ()     #   and one

Alternate solutions (also 8 bytes):
({}[]{})    # Sum + 1
([]{}{})    # Sum + 2

There's a bunch of other solutions that only work with positive numbers:
(<{}>{})
({}<{}>)
({{}}())
({{}()})
({{}}[])
({{}[]})

Vim, 3 bytes/keystrokes
<C-a>gJ

Try it online!
Note that <C-a> is actually ctrl-a, which represents byte 0x01.
I love it when vim (which isn't even a programming language) can compete with golfing languages. :) Input comes in this format:
a
b

This simply increments the first number by one (This is the <C-a> part) and then joins the string representations of the two numbers together. As far as I can tell, this should never result in the sum.

Jelly, 2 bytes
+‘

The + adds the two inputs together then the ' increments the answer by one
Try it online!

This answer makes me jelly.

I bet it does :P

Technically this is not (a+b)+1 but a+(b+1) because the dyad-monad chain fG is treated as f(a, G(b)). In this case it's the same thing but technically how it works is different :P

TI-Basic, 3 bytes
not(max(Ans

Alternative solutions:
10^(sum(Ans         3 bytes @DestructibleWatermelon
not(sum(Ans         3 bytes
1+sum(Ans           4 bytes
Input :X=Y          5 bytes @ATaco
Input :X+not(Y      6 bytes
Input :not(X+Y      6 bytes
Input :10^(X+Y      6 bytes
Input :X+Y+1        7 bytes
Input :not(max(X,Y  7 bytes
Ans(1)=Ans(2        8 bytes
Ans(1)+not(Ans(2    9 bytes
not(Ans(1)+Ans(2    9 bytes

It's interesting that you made the question's examples in TI-Basic, but you forgot the shorter A=B (or maybe it was up to us to find out?)

Nobody likes it when the OP posts a super short solution in the question, making it hard to beat.

@mbomb007 I suppose, but those were only snippets and not full programs. Adding Prompt A,B: to them brings the byte count to eight bytes each.

@Timtech Exactly. I didn't want to give good answers as examples, I just wanted examples.

@JulianLachniet I understand and appreciate that :)

Brachylog, 2 bytes
+<

Try it online!
Explanation
+     The sum of the elements in the Input...
 <    ...is strictly less than the Output
      (implicitely label the output with an integer respecting this constraint)

This will always result in A+B+1, if Input = [A, B].

Mathematica, 5 bytes
1+##&

Outputs the sum of the two arguments plus 1. For example, 1+##&[2,5] yields 8.
(Side note: Binomial almost works, although Binomial[1,0]=1 and Binomial[4,2]=6 are counterexamples; I think they're the only counterexamples, though.)

Pochhammer seems to be one better than Binomial. As far as I can tell only 1,0 fails.

Ah, and KroneckerDelta works for all inputs (being the equivalent of the equality check in some of the esolangs). It's actually shorter to reimplement as Boole[#==#2]&, but I assume you were looking for a built-in that works as is.

Java (OpenJDK 9), 10 bytes
a->b->a-~b

Try it online!

With currying, you can spare a byte: a->b->a-~b. Also works with Java 8, any edition (so there's no need to specify the OpenJDK 9)

@OlivierGrégoire Java has started to look like JS now >_>

@KritixiLithos Well... we had a hint this would happen for years: JavaScript ;-)

@KritixiLithos The specification for Java 9 has a section on 'ECMAScript 6 Compliance'.

@OlivierGrégoire Yeah, but this submission was generates automatically, which is why the 9 was added.

PHP, 17 bytes
<?=1-join($argv);

Run like this:
echo '<?=1-join($argv);' | php -- 0 0
> 1

Explanation
This just concatenates the arguments. The first argument (script name) contains -. So that results in a negative number, which I negate with the minus sign. Then I add 1, just in case the first input number is a 0 (0123 = 123).

Perl 6, 4 bytes
!*+*

A lambda (formed by Whatever-currying), that adds the boolean inverse (1 or 0) of the first argument to the second argument.
Try it online!

Turtlèd, 12 bytes
makes very large numbers
'1?:?:[1'0l]

Try it online!
Explanation:
'1                write one on the starting grid square
  ?:?:            take a number, move right that many (repeat)
      [1   ]      while not on a grid square with a one on it
        '0l       put a zero on that square, move left
[implicit output of grid]

It thus outputs 10**(x+y).

PHP, 19 bytes
1<?=max([0]+$argv);

brainfuck, 12 bytes
Simple solution that outputs A+B+1.
,>,[-<+>]<+.

Try it online

Alternate answer (12 bytes): ,>,[-<++>]<.

@JulianLachniet will that output A+2B?

A+2B hacked when B=0

@mbomb007 I'm saying the ,>,[-<++>]<. solution

@JulianLachniet Yeah, that's not a valid answer because A+2B for input B=0, gives A.

dc, 5 bytes
?1n+n

Try it online!
Input: Two natural numbers separated by a space on stdin.
Output: The digit 1 immediately followed by the sum of the two numbers, which is a number larger than the sum of the two numbers.
Example:
Input: 222 333
Output: 1555

SmileBASIC, 4 bytes
!A+B

not(A)+B
1+1=2 -> !1+1 -> 0+1=1
0+1=1 -> !0+1 -> 1+1=2

Out of curiosity, how does this support 2+1?

2+1=3 -> !2+1 -> 0+1=1

MATLAB / Octave, 3 bytes
@eq

Accepts two inputs and checks for equality and yields 1 if they are equal and 0 otherwise.
Online Demo

Shouldn't this be @eq? That returns a function handle which can be used to evaluate to the desired function, while just eq is meaningless.

@Sanchises I've seen many answers go both ways: http://codegolf.stackexchange.com/questions/106149/compute-the-median/106152#106152. I'm not actually sure which is preferred.

Hmmm. I should think this is more like a snippet, while an @ turns it into a valid language construct. But maybe I'm just being pedantic.

R, 13 bytes
sum(scan()+1)

Thanks to Jonathan Allan for his inputs !

@JonathanAllan : You're right, I changed my answer. Thanks !

OK, pretty sure 00 is the same as 0 though, maybe sep="1"?

@JonathanAllan : damnit ! Thanks again !

Looking at the Tips For Golfing In R it seems scan() should be fine, accepting a vector input, like this. But we can do one byte better with cat(sum(scan()+1)). Maybe there is shorter?

In this strategy, I don't think that cat is needed anymore, since we're no longer sticking numbers together.

With the cat it is a full program, the alternative would be an unnamed function for the same byte cost function(a,b)a+b+1

C 26 24 19 bytes
f(c,d){return!c+d;}

Ungolfed version:
int f(int c,int d)
{
   return !c+d;
}

I hope I got the specification right. Can definitely be shortened!?
@Pavel Thanks for saving 2 bytes
@Neil Thanks for your input.

Do you need () around !c+d?

@Pavel You're right, brackets were useless, updated!

Not 100% sure but I think you can remove the space in your return, like return!c+d;

Do you need the space after return? Do you need the int specification?

@Neil You're right they were both unnecessary. Updated. Sorry I come from the clean-code club. :) Have to get used to golfing in C.

@Metoniem Huh, your comment didn't show up when I was commenting, sorry for stomping on you like that.

@Neil Haha that's okay! I wasn't even sure about it, you just confirmed. I only assumed it would work because it also does in C# :)

Lose the return and instead assign it with something like c+=!d

Surely the ungolfed version should still have the int and spaces etc...

@Neil Thanks, will remember next time to leave the Ungolfed version clean.

@Ahemone I don't think that's considered output though?

@AlbertRenshaw While it's undefined and somewhat dependent on the calling convention the compiler uses and which registers used but from what I understand of GCC, on x86 at least, it will place any data it wishes to store in an offset position in memory in the same register as the return value so when the function exits with no explicit return the register designated to store the return value contains the last value that was stored somewhere in memory.

@Ahemone Could you provide a reference to this? I'm having a hard time reproducing this on any online C IDEs

@AlbertRenshaw It's not something I'd rely on for portability but here are a couple of examples. I can't get it to work offline and it seems that it needs to be assigned to a non argument variable on TIO.. https://tio.run/nexus/c-gcc#RY1LCgIxDED3PUWoCK1GcEBXxZt0099AFw2ljhuHOXuNVRhISPLyQg4xzZkSvFXAqKG2TMus5PFpaWS0ZEkiLzEPRfdgSDn0eg0Pd/Jm6@U38iUwOjMSdUc0LH9xjMUXFJdJ6VXA/i3CCImkbnjXCOVfq5ombrRhu6Xl1QiuRmz9Aw

@Ahemone wow thank you! Very impressive

@Ahemone can you post your 14 byte solution as an answer please? ʕ•ᴥ•ʔ

@AlbertRenshaw I have now done so with 13 bytes at http://codegolf.stackexchange.com/a/111339/64644 . AbelTom, I'm sorry for polluting your comments by promoting my answer.

05AB1E, 1 byte
Q

Works the same as the RProgN answer.
Checks if a and b are the same. If so, print 1. Otherwise, print 0
Try it online!

¢ ( a.count(b) ) should also work for 1 byte.

@Riley you could post that as your own answer.

It's not different enough to needs it's own answer. I thought we could just combine both 1 byte solutions into one answer.

PHP, 13 bytes; (17 REPL-less)
!max($argv)+0

Examples
[0,0] -> 1
[0,1] -> 0
[1,0] -> 0

For those without REPL use
<?=!max($argv)+0;

and run using
echo '<?=!max($argv)+0;' | php -- 0 0

This answer is not valid because it doesn't output anything

@aross If boolean cast was problem I updated my answer

Yes, you addressed both problems. The output would be true/false, not 1/0. Also, REPL :)

Cubix, 9 8 bytes
u-~OII/@

Explanation
Expanded, this answer looks like this:
    u -
    ~ O
I I / @ . . . .
. . . . . . . .
    . .
    . .

The order of the instructions that are executed is II~-O@
II~-O@
I      # First input
   -   # Minus
 I~    # NOT(second input)
    O  # Output as integer
     @ # End program

Tested for all combinations of inputs where both are in the range 0-100.
Try it here.

///, 10 bytes + input
/0/1//+//[input A]+[input B]

Obviously [input A] and [input B] are supposed to be replaced with the appropriate inputs
Try it online!
Changes 0's to 1's, then concatenates the strings.
This works because:

For A,B>0, join(A,B)>A+B
join(A,B)>join(C,D) if A>C or B>D
The function f(x)='change 0's to 1's in the digits of x' is always at least x

So we have join(f(A),f(B))>f(A)+f(B)>=A+B.
And if one or both of the inputs are 0, we have join(1,B)>1+B>0+B, join(A,1)>A+1>A+0 and join(1,1)=11>0+0.
Note 1: This type of input has been approved by the community
Note 2: This output doesn't give leading 0's either
Note 3: Less bytes than Python, PHP, C#, C, Powershell and more!

APL - 4 Bytes
1++/

Takes array, sums its elements and adds one.
Test:
 1++/1 2
4
 1++/1 0
2

√ å ı ¥ ® Ï Ø ¿, 4 bytes
II1_

II   Take 2 inputs and push to the stack
  1  Push 1 to the stack
   _ Push the sum of the stack

To output, add o to the end.

Hexagony, 7 bytes
?<.!?)@

Try it online!
Or in more readable format,
 ? <
. ! ?
 ) @

This beats the current Hexagony solution of 11 bytes.
Explanation:
If the first number is not 0, the program takes the following path:

This reads the first number and branches right. Then it reads the second number, followed by wrapping and trying to read a third, but that doesn't exist so it reads 0. This is printed and the program terminated (note that if a>0, since b is non-negative a+b>0).
If the first number is 0, the program takes the following path to start with:

This reads the first number and branches left. It hits the corner, taking the route from along the north-west edge because the number is 0, and reads the second number. It wraps, then increments the second number and prints.

It bounces against the <, printing the incremented second input again. It increments the value and takes the north-east edge again, but this time because the current edge a twice-incremented non-negative value which is definitely positive. It then tries to get a third input, but receives 0 instead.

Finally it wraps and gets diverted by the arrow, then tries to read a fourth input and gets 0 again. It wraps and tries to read a fifth input and receives 0 for the last time. This it prints, and wraps to the @ and exits.
Note that b*(10^k+1)*10>0+b=b where k is the length of b in digits, so this works.

CJam, four 3 bytes
q~=

Try it online!
Explanation
q~   e# Read the input and eval it (pushes the numbers on the stack).
  =  e# Check equality.

O, 4 bytes
jj=o

The same as other implementations.  Get the numbers, test the equality and output.  Try it here
j    Number input
 j   Number input
  =  Equal to
   o Print object

Forth, 5 bytes
I didn't see Forth on the list, this is the A+B+1 solution.
+ 1 +

It adds the top 2 numbers on the stack, then adds one to it.
The answer will be the top value on the stack.
Example:
=> 4, 5
+ 1 +
=> 10

This can be + 1+, since there is a separate word for 1+. But according to other answers, you could just use =. Also, I'm pretty sure Forth needs to use . for output unless you define a new word. This is as close to a snippet as you can get.

Clojure, 11 bytes
#(+ % %2 1)

Unoriginal. Just adds 1 to the sum of % and %2 (the arguments to the function).

Beam, 4 bytes
This seems a bit cheaty, but it reads from the input (characters only) and outputs the ASCII values for each.
>r:!

Try it online!
>     # redirect right
 r    # read input character
  :   # output numeric value of beam
   !  # if beam <> 0 reflect back

The Halt command is required on here as the beam just disappears into the aether.

Cheddar, 11 bytes
(a,b)->a-~b

Try it online!

SQLite, 23 22 bytes
Saved 1 byte thanks to MickyT
select 1+sum(v)from i;

By default, SQL variants can take input from a named table. In this case it takes two numbers from the column v in the table i, sums them, and adds 1.
Try it online!

You can save a byte switching the order of the addition and removing the space before the from. select 1+sum(v)from i;

Billiards, 11 characters = 17 bytes
⇲
⇲
+
1
+
↥

Implements x + y + 1. Pretty elementary. It takes the inputs on two separate lines. (By the way, the language was modified slightly after the challenge, but only to suppress the prompt from inputting, not sure if this answer is still valid).
7 characters = 11 bytes, non-competing
This one is shorter but only possible after a new update of the language:
⇲
⇲
=
$

This uses x == y, which was shamelessly stolen from @ATaco's RProgN solution [ hope you don't mind (: ]. The $, on exit, outputs how many balls passed over it.

slightly after the language typo, also I think when the language had the input prompt, it would still be valid. I don't think output standards are that strict, and non-suppressible outputs are allowed I think

@DestructibleWatermelon Oh, that was a weird typo. Thanks for the clarification. I actually modified the language, then came and saw the challenge, so I decided to add that note in there in case anyone decided to be picky about checking when the push was made to GitHub, but thank you for clarifying that.

Carrot, 3 bytes
1$$

Try it online!
(input is newline separated)
Similar to ais529's answer, except this takes care of leading zeroes. This outputs 1 concatenated with both the input numbers. So 5\n6 outputs 156.
Alternate solutions:
6 bytes
1$$^*1

Same thing as the above solution, but concatenates it with a copy of itself. So 5\n6 becomes 156 which then becomes 156156.
8 bytes
#^A +1+

(note the trailing space, the input is space separated this time)
#^A +1+
#^                        //gets all of the input
  A                       //convert it an array splitting on spaces
   +1                     //add 1 to each of the array's elements
     +                    //sums up all the elements in the array

C#, 32 bytes
Golfed
int i(int x,int y){return++x+y;}

Ungolfed
int i (int x, int y)
{
    return ++x+y; //Returns X+Y+1
}

Ruby, 9 bytes (8 + -n flag)
p~/1/||1

Input 2 integers separated by comma or space or semicolon or just whatever.
Explanation:
If the input string does not contain any '1', output '1' (since the sum can't be one).
If the input string is 3 characters long, the position of the first one can be 0 or 2, the sum can't be zero, and only '1 1' has sum two (but the first '1' is at position zero).
If the input string is longer, we don't care, the sum will be bigger than one and bigger than the position of the first '1'.

Javascript (ES6), 10 Bytes
x=>y=>!x+y

Put f= before the code and run like f(x)(y).
This will output y plus either 0 or 1 depending on whether x is truthy or falsy, respectively.
Thanks to TomDevs for the bytes saved

You can save 1 byte by currying and the output doesn't have to be 0 or 1, so you can save a further 4 bytes: x=>y=>!x+y, at is ran by (x=>y=>!x+y)(1)(2)

@TomDevs Oh yea I totally forgot about currying and thanks for the output tip as well.

Pyke, 1 byte
q

Try it here!
This is the only 1 byte solution that works in Pyke, all the others have collisions.

Javascript, 12 bytes
(a,b)=>a+b+1

Accepts 2 numbers inside a closed lambda and return their sum plus 1
Example:
((a,b)=>a+b+1)(1, 2)
// 4

You can save two bytes by removing the outer pair of parentheses :-)

I think that will break the IIFE

We allow any expression that returns a reusable function as a valid entry. Here, (a,b)=>a+b+1 is a perfectly valid function expression; you can assign it to a function with f= and then call it like f(1, 2) as many times as you want.

currying, i.e. a=>b=>a+b+1 is shorter. you then call it with f(1)(2)

Does not work for inputs 1e53 and 0.

QBIC, 8 bytes
a bit uninteresting:
::?a+b+1

This just takes A and B from the cmd-line, adds them plus 1.

Hexagony, 11 bytes
?}?@!<."+)/

Prints X + Y + 1
Try it online!

The expanded Hex:
  ? } ?
 @ ! < .
" + ) / .
 . . . .
  . . .

read into the initial memory edge.
go forward to the right and read into that one.
wrap around to the middle row.
go backward to the left and sum the other edges into this one.
increment.
redirect NW then W to save a byte.
print and exit.

C (gcc), 13 bytes
n(a,b){a=&b;}

returns b's address in memory, though it's slighty cheaty since the user is able to predict the address of b.
Try it online!

Very nice! I was trying to get less than 14 and couldn't!

why not n(a){a=&a;}

@l4m2 The question requires 2 inputs

n(a){a=&a;} main(a,b){return n(1,2);} works fine

Do you know why that works?

Milky Way 2 bytes
b!

Checks equality.
http://meta.codegolf.stackexchange.com/a/8493/63187  allows me to assume the inputs are pushed to stack.
Thank you Zach Gates! I out golfed him in his own language :P

You still need to output your result (use ! or ¡). Best alternative I've come up with so far is l+¡.

@ZachGates OK thanks! Good luck

@ZachGates one I had was +R+! Then found the other way

PHP, 22 bytes
eval("echo $argn+1;");

A port of ConnorLSW´s answer. Run with echo "<a>+<b>" | php -R '<code>'.

Python, 25 17 bytes
Takes an array of numbers n, and returns their sum + 1:
lambda n:sum(n,1)

I just translated https://codegolf.stackexchange.com/a/111845/66068 into python.

Anonymous functions are allowed here so you can remove the f= to save 2 bytes. Also replace nums with n to save 6 bytes. lambda n:sum(n,1) for 17 bytes. Also your original is 25 bytes.

Keg, 5 bytes
Input two natural numbers separated with spaces.
?(+).

Sums the whole stack. The answer is guaranteed to be invalid, since what it sums is the charcodes of the numbers.
TIO

naz, 56 bytes
6a8m2x1v1x1f1r3x1v2e0m1o0x1x2f2r3x1v3e0m1o0x1x3f1a1o0x1f

Takes two natural numbers as input, separated by a space.
Explanation (with 0x commands removed)
6a8m2x1v         # Set variable 1 equal to 48 ("0")
1x1f1r3x1v2e0m1o # Function 1
                 # Read the first byte of input, removing it from the input string
                 # Jump to function 2 if it equals variable 1
                 # Otherwise, output 0
1x2f2r3x1v3e0m1o # Function 2
                 # Read the second byte that's still in the input string
                 # Jump to function 3 if it equals variable 1
                 # Otherwise, output 0
1x3f1a1o         # Function 3
                 # Output 1
1f               # Call function 1

Flurry, 12 bytes
[]{<{}{}>}{}

Run example
$ printf "0 0" | ./flurry -nib -c "[]{<{}{}>}{}"
73728
$ printf "0 1" | ./flurry -nib -c "[]{<{}{}>}{}"
75264
$ printf "0 11" | ./flurry -nib -c "[]{<{}{}>}{}"
3687936

Takes two numbers separated by single space from stdin in binary mode, and prints the return value as an integer.
The binary mode is the trick here. What the program does is to implicitly push all codepoints of stdin to the stack, and print the product of the entire stack.
Code explanation
// Pop (stack height + 1) times and compute the product;
// popping from empty stack gives I = 1
//     []     {<{}{}>}  {}
main = height times-pop pop

//          {   <{}  {}  >}
times-pop = \x.  x ∘ pop

Proof that this does not give a+b for any a b
Base case: The input of "0 0" gives 48 × 32 × 48 = 73728.
Inductive case:

The codepoint of any printable ASCII is 32 or above, so adding a digit (which amplifies a+b by at most 10) amplifies the output by 32 or above.
Adding 1 to an existing digit adds the product of all the codepoints except itself to the output, which is much greater than the digit value of the modified digit.

Therefore, the output grows much faster than the value of a+b, and they can never be equal.

For comparison, here is the program that computes a+b+1:
Flurry, 18 bytes
{}(<><<>()>)[{}{}]

$ ./flurry -nin -c "{}(<><<>()>)[{}{}]" 12 13
26
$ ./flurry -nin -c "{}(<><<>()>)[{}{}]" 0 0
1
$ ./flurry -nin -c "{}(<><<>()>)[{}{}]" 0 10
11

// initial stack = a b
//     {}  (<><<>()>)  [{}   {} ]
main = pop (push succ) (pop  pop)
//     b                succ a
     = b succ (succ a)
     = b + succ a = a + b + 1

Haskell, 8 bytes
(+).succ

Try it online!
I'm certain this could be shorter but I haven't found a solution yet.

Chaincode, 2 bytes
a+

Explanation:
a   #Adds two input values
 +  #Increment

Lua, 25 bytes
x={...}print(x[1]+x[2]+1)

Try it online!
Just a trivial A+B+1 solution.

Powershell, 15 Bytes
("$args"|iex)+1

input is in any standard mathematical format, 1+1,2+2,5123-123213,200*99,1234/555 etc.
Just takes input, invokes (calculates) it, then adds one at the end.

Labyrinth, 6 bytes
??+)!@

Try it online!
Takes two number inputs, prints their sum + 1.

Scala, 26 Bytes
var n=(a:Int,b:Int)=>a+b+1

Clack, 3 bytes
1++

Since clack has very few instructions at the moment, the shortest method is to just push 1, the two numbers, and add them.

C, 18 bytes
#define f(a,b)a==b

try it online

#define f(a)a== calling currying lol

><>, 3 bytes
Also see this post, but ><> needs the explicit print and termination so we can't go under 3 bytes.
=n;

But this is a pretty boring solution. There are two 5 byte solutions
1nnn;

and
1++n;

that are only slightly more interesting. For input a and b, the first one works by printing 1ba and the second by printing a+b+1.
Here is a TIO test bench where bytes 2-5 should be replaced by the first 4 bytes of a solution.

Java - 44 bytes
int n(int a,int b){return Math.abs(a+(-b));}

Returns an absolute value of a + (-b)
Ungolfed version:
int n(int a, int b) {
    return Math.abs(a + (-b));
}

Wouldn't it fail for 0 and 0?

@MatthewRock didnt check that. I willfix it tomorrow

Isn't a+(-b) equivalent to a-b?

ForceLang, 33 bytes
def a io.readnum()
io.write a+a+1

Does this take two numbers as input?

@muddyfish Yes.

Cardinal, 7 bytes
%:+~:*.

Outputs sum + 1
Try it online!

Windows batch, 24 23 17 bytes
@cmd/cset/a%1+%21

Test cases:
Tested on Win10 64-bit
Foo\Bar\Baz>NotCalc.bat 1 55
552

Note: batch files are limited to 32-bit signed integer!

isn't 0+0 with a trailing 0 00, which is 0?

Oh yeah. I forgot that

I tested it for you (also on Win7 64-bit). 1+55 returns 552. I don't understand the program well enough to explain why it returned that and not 561, but I tried some other inputs and got more weird results like 5+9=96. I'm not sure why that is, but my limited testing didn't find anything that outputs a correct sum...

It adds a trailing one to 55 so it becomes 551, 1+551=552 and 9 became 91, 5+91=96

Oh, I see. I thought it was adding a 1 to the result.

@undergroundmonorail can you help me test this code: @cmd set/a%11?

Melang (Non competing) 13 bytes
\n\n+\n+\n\ni

I wrote Melang for this challenge and decided that it works so might as well bring it here.
Adds the numbers inputted together and adds one. For more on the language and to try it out visit here.

Wait,  those aren't literal newlines?

@ascii nope! Literal newlines error my implementation due to the website restrictions

How does it error in your implementation?

@ascii the way string inputs are taken in the website I used to write it breaks it

well that's a JS implementation limitation not a melang implementation limitation, you do know you can make it a Stack Snippet and it would work right?

It is a esolang. Also I only have mobile (spring break)

Let us continue this discussion in chat.

Haskell, 11 9 bytes
(succ.).(+)

Adds together and then adds 1
EDIT: Of course, if you want to go with the boring answer:
a#b=a+b+1

is 9 bytes.

Non pointfree a#b=1+a+b is two bytes shorter.

c++, 28 bytes
[](int a,int b){return!a+b;}

Try it here

Japt, 3 bytes
NxÄ

Try it online

Explanation
N   :The array of all inputs
x   :Sum the array
Ä   :Add one to each element

Aceto, 9 bytes
ir+1
ri+p

Super straightforward. Prints the sum of the two inputs and 1. If I can assume for the inputs to be on the stack already, there's a 5-byte solution:
1+
+p

Braingolf, 3 bytes
g1+

Appends the inputs to eachother (ie 17, 4 becomes 174), then increments by 1.
Notable testcases:
[0, 0] becomes 00, becomes 01
[0, 1] becomes 01, becomes 02
[1, 0] becomes 10, becomes 11
[1, 1] becomes 11, becomes 12

00 is equivalent to 0+0 = 0 as noted in the comments for Windows Batch (among others)

MarioLANG, 35 bytes
;
)
;
>[!(+:
"=#===
) -
+ (
! <
#="

Reads two inputs and puts them in differents cells (variables). Increments one and decrements the other until the second number is zero. Then adds one  calculate the wrong answer.

Underload, 23 bytes
((::)~*)~(~)~*a*^*(**)*

Takes input in the form of Church numerals on the stack and outputs to the stack.
Try it online!

Excel VBA, 13 Bytes
Anonymous VBE immediate window function that takes input from range [A1:B1] (... or really any range that is a subset of [1:1], I suppose) and outputs their sum +7
?[Sum(1:1)+7]

Perl 5, 8 bytes
7 bytes of code + 1 flag (-p)
$_+=!<>

Try it online!

Pretty sure perl gets -p free.

Implicit, 2 bytes
+.

Try it online!
+.   implicit input of two integers
+    add them
 .   and increment

= also works for 1 byte, but I added that to the existing list of =s.

Aceto, 6 bytes
rrJiIp

r reads input and puts on stack (x2)
J concatenates top 2 values
i makes it an integer
I increments it
p prints it
Try it online!

x86 opcode, 2 bytes
INC EDX
RET

input EAX and EDX, output EDX:EAX
If D':A=D+A then D has to be zero, making the equation still not correct
x86 opcode __cdecl, 3 Bytes
MOV DL, 3
RET

MAWP, 4 bytes
@MM:

adds the numbers to the 1 in stack.
Try it!

Fails at 0 0, giving 0 as output.

Invalid submissions need to be deleted, sorry :P.

For our purposes, 0 is natural (although not all mathematicians agree). does this note not apply?

Of course it apply, so your program is invaild.

The problem isn't that 0 is natural. The problem is that for an input of 0 0, your code outputs 0, which is the sum of the two inputs.

Ok. Got it. Now it's correct.

That's totally unfair. 1++ will have implicit I/O...

Google Sheets, 9
=--(A1=A2

If A1=A2, the sum is even, but the output is always 1, which is odd.
If A1<>A2, then the sum is positive, but the output is always 0, which is not positive.

Why didn't I use =A1+A2+1? Because if I input a sufficiently large number and 0, the +1 does  nothing.

HBL, 2 bytes
+.,1

Try it at HBL Online!
Explanation
+     Add
 .    the first argument
  ,   the second argument
   1  and one

Vyxal HṪ, 2 bytes
□∑

I had to post this as it is quite obfuscated.
Try it Online!
Explanation
□∑
□   # Get input treated as a list separated by newlines.
 ∑  # Sum the list together.

 Created with the help of Luminespire at https://vyxal.github.io/Luminespire

With the explanation above, it seems like that this returns the correct sum. But if you think this, then you haven’t paid attention to the flags.
HṪ
H   # Before execution, push 100 to the stack.
 Ṫ  # After execution, take the sum of the whole stack and print it.

 Created with the help of Luminespire at https://vyxal.github.io/Luminespire

Now that you have the full picture, you realise that it adds 100 to the result.

Acc!!, 31 bytes
Count i while N-10 {
Write 57
}

Takes the two numbers space-separated. Try it online!
Explanation
Count i while N-10 {   # While input character is not a newline:
    Write 57           # Output 9
}

To prove that the output is always valid, consider the following numbers:

A + B = the sum of the input numbers
AB = the concatenation of the input numbers (equal to A * 10 ^ (len B) + B)
N = a number of the same length as AB but composed of all 9's
N+ = N with an extra 9 concatenated (equal to N * 10 + 9)

The output of this program is N+ (the extra 9 comes from the space between the input numbers). Looking at the formulas, we have A + B <= AB, AB <= N, and N < N+; therefore, this program's output is always greater than (and therefore not equal to) A + B.

brainfuck, 18 bytes
,[>-[----->+<]>.,]

Try it online!
Output is always lot larger than input

Zsh, 8 bytes
<<<9$1$2

Try it online!
Concatenates 9 A B which is always larger than A + B

GolfScript, 3 bytes
Input is to be taken as two separate lines. In GolfScript, a preceding 0 is allowed for numbers.
n/0

Try it online!
Explanation
# Two inputs taken with newlines
n/  # Split the input (separated by newlines) with newlines
  0 # Add a 0 to prevent a preceding 0
    # Implicit concatenation

GolfScript, 3 bytes
~+)

Try it online!
Explanation
~   # Evaluate the input
 +  # Add the two numbers
  ) # Increment the sum

1+, 6 bytes
..+1+:

As usual. a + b + 1.

Just FYI, a few of your 1+ answers have been popping up in the low-quality posts queue recently (autoflagged). I haven't noticed any problems with the code in any of these posts, but I do think your answers would benefit from a bit more explanation.

@Dingus Oh, ok. Although this answer (and a couple others) is really naive and I don't see how to add an explanation...

J, 3 bytes
+>:

Try it online!

Thunno 2, 1 byte
=

Attempt This Online!
Port of @ATaco's RProgN answer.

J-uby, 8 bytes
:+%:succ

Attempt This Online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/