# 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?
– xnor
Feb 13, 2017 at 3:01
• Can the output have leading zeroes? Feb 13, 2017 at 8:27
• I presume overflows need to be taken into account, so the result of 2^32 -1 and 2 should not be negative, right? Feb 13, 2017 at 12:28
• 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. :) Feb 13, 2017 at 17:11
• @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. Feb 13, 2017 at 17:16

# RProgN, 43 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 <s>4</s>/4 Feb 14, 2017 at 1:10
• @RohanJhunjhunwala hold my 4, I'm going in Feb 14, 2017 at 3:20
• ̶4̶ <-- u+0336 (combining character) may be a better way to do it Feb 14, 2017 at 3:23
• PSA: codegolf.stackexchange.com/questions/48100/… Original crossed out thing Feb 27, 2017 at 23:50
• @AlbertRenshaw the old PPCG crossed-out-4-a-roo? Mar 7, 2017 at 16:36

# 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
– Blue
Feb 13, 2017 at 12:48
• @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.
– xnor
Feb 13, 2017 at 13:32
• IMO if it swims like a number and quacks like a number, it's reasonable to assume it's a number. Jun 19, 2017 at 17:47

# 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. Feb 13, 2017 at 3:59
• @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?
– user62131
Feb 13, 2017 at 4:04
• Or . 1 if you don't want to return leading zeros yourself. Feb 13, 2017 at 14:48
• @MartinEnder > but is a natural number Feb 14, 2017 at 19:43
• @wizzwizz4 I'm not following. Feb 14, 2017 at 19:44

# 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.

• 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.
– user62131
Feb 13, 2017 at 3:01
• @ais523 Updated to include that. Thanks. Feb 13, 2017 at 3:07
• Also in Stacked. Try it online! Feb 13, 2017 at 16:36
• Can you add APL and J?
Feb 14, 2017 at 18:08
• @Adám Sure thing. Do you have a TIO link that I can link to? Feb 14, 2017 at 18:19

# 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! :) Feb 13, 2017 at 22:04
• Thanks =) I've been reading challenges for a while, just trying to find a good place to start. Feb 14, 2017 at 13:52

# 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.

# 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:

(<{}>{})
({}<{}>)
({{}}())
({{}()})
({{}}[])
({{}[]})


# 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. Feb 13, 2017 at 20:20
• @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. Feb 13, 2017 at 22:14
• @Timtech Exactly. I didn't want to give good answers as examples, I just wanted examples. Feb 15, 2017 at 11:57
• @JulianLachniet I understand and appreciate that :) Feb 15, 2017 at 15:32

# Jelly, 2 bytes

+‘


The + adds the two inputs together then the ' increments the answer by one

Try it online!

• This answer makes me jelly. May 20, 2017 at 1:56
• I bet it does :P May 20, 2017 at 19:34
• 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 May 17, 2018 at 12:29

# 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. Feb 13, 2017 at 12:05
• 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. Feb 13, 2017 at 12:08

# 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!

# 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) Feb 14, 2017 at 9:20
• @OlivierGrégoire Java has started to look like JS now >_> Feb 14, 2017 at 9:34
• @KritixiLithos Well... we had a hint this would happen for years: JavaScript ;-) Feb 14, 2017 at 10:01
• @KritixiLithos The specification for Java 9 has a section on 'ECMAScript 6 Compliance'. Feb 14, 2017 at 15:33
• @OlivierGrégoire Yeah, but this submission was generates automatically, which is why the 9 was added. Feb 14, 2017 at 15:33

# Turtlèd, 12 bytes

makes very large numbers

'1?:?:[1'0l]


## 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(+$argv);  # HODOR, 40 bytes (non-competing) This is probably the shortest program Hodor's ever written! This is what happens when you have nothing to do for a 2-week school holiday: produce a bunch of really easily coded joke languages that do absolutely nothing. Yay for school holidays!!! Walder Hodor?! Hodor?! Hodor HODOR! HODOR!!!  Walder was Hodor's original name and so is needed to begin the program. Hodor?! takes either a number from STDIN or a single character and sets the accumulator to the input Hodor add 1 to the accumulator HODOR! outputs the accumulator as a number HODOR!!! kills Hodor! Noooooo! This is the pseudo code: Take input Take input Add 1 to sum(inputs) Output value  • I think you need to come up with a different name for your language unless this is an interpreter of the pre-existing Hodor language created in 2015, which I'm fairly certain this isn't. Apr 5, 2017 at 13:52 • @mbomb007 No that isn't mine but there are languages with duplicate names. I know of two called 7 on this site (I just can't find them at the moment) Apr 5, 2017 at 13:58 • I'm pretty sure there's only one called 7, and it's this one. You could change the capitalization of the title for an easy fix, something like HODOR. Apr 5, 2017 at 13:58 • @mbomb007 mine is Hodor and theirs is hodor so that could be enough? Apr 5, 2017 at 14:01 • No, theirs has a capital H, as you can see from every time he uses the language name on his website. Apr 5, 2017 at 14:01 # 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? Feb 13, 2017 at 1:53 • 2+1=3 -> !2+1 -> 0+1=1 Feb 13, 2017 at 1:54 ## R, 13 bytes sum(scan()+1)  Thanks to Jonathan Allan for his inputs ! • @JonathanAllan : You're right, I changed my answer. Thanks ! Feb 13, 2017 at 7:06 • OK, pretty sure 00 is the same as 0 though, maybe sep="1"? Feb 13, 2017 at 7:08 • @JonathanAllan : damnit ! Thanks again ! Feb 13, 2017 at 7:38 • 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? Feb 13, 2017 at 7:54 • 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 Feb 13, 2017 at 8:10 # 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. Feb 13, 2017 at 16:54 • @Riley you could post that as your own answer. – Okx Feb 13, 2017 at 17:48 • It's not different enough to needs it's own answer. I thought we could just combine both 1 byte solutions into one answer. Feb 13, 2017 at 17:49 ## C 2624 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? Feb 13, 2017 at 7:48 • @Pavel You're right, brackets were useless, updated! Feb 13, 2017 at 8:07 • Not 100% sure but I think you can remove the space in your return, like return!c+d; Feb 13, 2017 at 8:50 • Lose the return and instead assign it with something like c+=!d Feb 13, 2017 at 10:22 • @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.. tio.run/nexus/… Feb 14, 2017 at 6:44 # 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. Feb 13, 2017 at 8:16 • @Sanchises I've seen many answers go both ways: codegolf.stackexchange.com/questions/106149/compute-the-median/…. I'm not actually sure which is preferred. Feb 13, 2017 at 13:30 • 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. Feb 13, 2017 at 13:58 # brainfuck, 12 bytes Simple solution that outputs A+B+1. ,>,[-<+>]<+.  Try it online • Alternate answer (12 bytes): ,>,[-<++>]<. Feb 13, 2017 at 20:37 • @JulianLachniet will that output A+2B? Mar 8, 2017 at 13:37 • A+2B hacked when B=0 – l4m2 Dec 15, 2017 at 18:48 • @mbomb007 I'm saying the ,>,[-<++>]<. solution – l4m2 Dec 18, 2017 at 21:04 • @JulianLachniet Yeah, that's not a valid answer because A+2B for input B=0, gives A. Dec 18, 2017 at 22:40 # 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 # 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 Feb 14, 2017 at 8:57
• @aross If boolean cast was problem I updated my answer Feb 14, 2017 at 11:29
• Yes, you addressed both problems. The output would be true/false, not 1/0. Also, REPL :) Feb 14, 2017 at 11:46

# 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.

# APL - 4 Bytes

1++/


Takes array, sums its elements and adds one. Test:

 1++/1 2
4
1++/1 0
2


# ///, 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!

# √ å ı ¥ ® Ï Ø ¿ , 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.

• is that supposed to say 4 bytes? Jul 9, 2017 at 15:05
• @TaylorScott I don't know what you're talking about :) Jul 9, 2017 at 15:52
• Oh I must have been mistaken ;P Jul 9, 2017 at 15:54

# 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.