Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list.

Output: Their sum. Use the same format for output integers as input integers. For example, the input 5 16 would lead to the output 21.

Restrictions: No standard loopholes please. This is , answer in lowest amount of bytes wins.

Notes: This should be fairly trivial, however I'm interested to see how it can be implemented. The answer can be a complete program or a function, but please identify which one it is.

Test cases:

1 2 -> 3
14 15 -> 29
7 9 -> 16
-1 8 -> 7
8 -9 -> -1
-8 -9 -> -17


Or as CSV:

a,b,c
1,2,3
14,15,29
7,9,16
-1,8,7
8,-9,-1
-8,-9,-17


var QUESTION_ID=84260,OVERRIDE_USER=8478;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

• This is quite trivial, but not really simpler than, e.g., the Hello World catalog. Given that the ability to add integers is one of our two requirements for programming languages, I'd say it's worthwhile to have if properly specified. – Dennis Jul 2 '16 at 0:48
• Can the answer take input with preceding zeros as default? e.g. 5 16 is inputted as 005 016 – FinW Dec 4 '16 at 11:56
• @FinW Sure. As long as they don't get interpreted as octal. – dkudriavtsev Dec 4 '16 at 20:47

# C, 66 bytes

Typical C omissions with regard to declarations, header files, and return statements. This actually works for any number of decimal integers (up to the limitations of one's shell), including none. The program can be invoked with ./a.out 1 2 [...], as an example.

main(c,v,x)char**v;{x=0;while(c-1)x+=atoi(v[--c]);printf("%d",x);}

Or, more legibly:

main(c,v,x) char**v; {
x=0;
while(c-1) x+=atoi(v[--c]);
printf("%d",x);
}

• You don't need to have a full program. Just int f(int a,int b){return a+b;} would probably suffice. – dkudriavtsev Nov 1 '16 at 2:11
• The challenge stated program or function. I make no claims to have the best solution. Additionally, another user has already provided a standalone function, and to produce an identical one would not contribute much. – James Murphy Nov 1 '16 at 2:27

## QBIC, 6 bytes

::?a+b


It takes two cmd line params as numbers (with two :'s), names them a and b, and adds them while printing (?).

## Euphoria, 64 bytes

Code:

include get.e
print(1,prompt_number("",{})+prompt_number("",{}))


# TI-Basic, 2 bytes

Very straightforward.

sum(Ans


# PigeonScript, 1 byte

+


Explanation: + pops the last two items from the stack, adds them, and pushes the result to the stack. Since there is nothing on the stack, the user is prompted for input twice. The inputs are pushed, popped, added, pushed, and the program ends, outputting what's on the stack (the result of input1 + input2)

# Whirl, 32 bytes

01100100001100011110001000111100


Try it online!

### Explanation

Whirl has two "rings" of operations, one for control and I/O operations and the other for math operations. The 1 command rotates the current operation ring while the 0 command switches direction of the rotation. Two 0s in a row run the current operation and switch to the other ring.

01100    Read an integer from stdin and store it at the memory pointer
100      Load that value into the math ring data storage
00       Read an integer from stdin and store it at the memory pointer
1100     Add the the values under the memory pointer to the math ring data storage
0111100  Set the control ring data storage to 1
0100     Save the math ring data storage to the memory at the memory pointer
0111100  Print the result from the memory at the memory pointer


# V, 2 bytes

À


Try it online!

You can't see it, but after the À there is a control-a character (ASCII 0x01).

This answer is nice because it shows one of the nice things about V: Numeric input is more convenient. Note how one input is an argument and the other is in the "input" field. This is an allowed input method, and it saves bytes because we want to run something n times, in this case the increment command or ctrl-a.

À           " Arg1 times:
<C-a>      "   Increment the next number found on this line


# SmileBASIC, 13 bytes

INPUT A,B?A+B

• “Input: Two decimal integers. These can be given to the code in standard input, as arguments to the program or function, or as a list.” Sure your code handles input? – manatwork Jan 24 '17 at 8:43
• Ok, I fixed it. – 12Me21 Jan 24 '17 at 16:19

## Python 3, 22 bytes

lambda a,b:a+b


Trivial answer for a kind of trivial question.

• You could golf this to lambda a,b:a+b. Although there's already a 3-byte python solution here. – FlipTack Dec 24 '16 at 21:43

# Taxi, 418 bytes

Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to The Babelfishery.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:w 1 l 1 r.Pickup a passenger going to Addition Alley.Pickup a passenger going to Addition Alley.Go to Addition Alley:e 5 l 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:w 1 r 1 r.Pickup a passenger going to Post Office.Go to Post Office:e 1 l 1 r.


Try it online!

# Wise, 9 bytes

[?~-!-~]|


Try it Online!

Takes 2 numbers in, A, and B.

             Implicit input
[ .... ]     While the top (B) != 0, repeat:
?           Move B to the bottom
~-         Add 1 to the top (A)
!        Move B back to the top
-~      Subtract 1 from the top (B)

|    Gets rid of the 0 on top by ORing the top 2
Implicit output


It boils down to "Add 1 to A, B times."

Less cool than the other Wise answer, but also shorter.

# Sinclair ZX80 BASIC (4K ROM)

The usual rules about the ZX80 and its 16 bit signed integer range apply here. Anything out of this range will not add. And because PRINT A+B is too easy, I came up with two solutions:

### Method 1 ~64 bytes:

This assumes that you're adding a positive integer to the first number entered:

 1 INPUT A
2 INPUT B
3 IF B=0 THEN GO TO 7
4 FOR B=B/B TO ABS(B)
5 LET A=A+1
6 NEXT B
7 PRINT A


### Method 2 ~24 bytes

A much simpler solution, where you are adding two -/+ integers together, simply do this:

 1 INPUT A
2 INPUT B
3 PRINT A+B


Both of these listings are likely to work on all variants of 8-bit BASIC, although would not be optimised on most of them.

• There are no such things as functions on a Sinclair ZX80 (as far as I know anyway) so both solutions are complete symbolic listings. – Shaun Bebbers Mar 28 '17 at 20:55

# Braingolf, 1 byte

+


Try it online!

# Triangular, 6 bytes

$.$%+<


Try it online!

Formats into this triangle:

  $.$
% + <


Without directionals or no-ops, the above turns into this: $$+% Triangular uses postfix notation. •  - read input as integer • + - add • % - print as integer # ,,,, 1 byte +  Body must be at least 30 characters; you entered 14. # Commentator, 4 bytes ////  Outputs by char code. If this isn't allowed, a 6 byte solution is ////*/  which outputs by numerical value. # tcl, 10 expr a+b If you have namespace path tcl::mathop you can do it shorter for every arithmetic operation: # tcl, 7 + a b test case on: http://rextester.com/live/FLFPTH24568 # Little Man Computer, 23 bytes (source) INP STA 6 INP ADD 6 OUT  ## With HLT, 27 bytes (source) INP STA 6 INP ADD 6 OUT HLT  Online Emulator (Flash) # Bitwise, 89 bytes IN 1 &1 IN 2 &1 LABEL &1 AND 1 2 *1 XOR 1 2 *2 SL *1 &1 1 MOV 2 *2 &1 JMP @1 *1 OUT *2 -1  Input and output are raw byte values as that is the only method of I/O for this language. Allowed per this consensus. Try it online! Ungolfed, written properly, and commented: IN 1 &1 -1 read a character into r1 if l1 truthy, discarding result IN 2 &1 -1 read a character into r2 LABEL &1 create label 1 here AND 1 2 *1 set fr1 to r1 & r2 where & represents bitwise AND XOR 1 2 *2 set fr2 to r1 ^ r2 where ^ represents bitwise exclusive or SL *1 &1 1 set r1 to fr1 << 1 where << represents bitwise left shift MOV 2 *2 &1 move fr2 into r2 if &1 truthy JMP @1 *1 jump to label 1 if fr1 truthy OUT *2 &1 -1 print frame register 2 if l1 truthy, discarding result  Note that fr is short for frame register, r is short for register and l is short for literal. # Bash script, 12 bytes expr 1 + 2  Save as add.sh, then run bash add.sh [argument] [argument]. • I think this should have been posted as an edit to your previous answer. – Dennis Jul 2 '16 at 22:10 • @Dennis These are somewhat separate: this one has to be run from a file, the other one can be run from the command line. – dkudriavtsev Jul 2 '16 at 22:12 • Yes, I'm aware. I don't think they're different enough to warrant separate answers though. The other does exactly the same; it just wraps the program in a function declaration. – Dennis Jul 2 '16 at 22:18 • @Dennis Okay... – dkudriavtsev Jul 2 '16 at 22:18 # INTERCAL, 74 bytes DO WRITE IN .1 DO WRITE IN .2 DO (1000) NEXT PLEASE READ OUT .3 DO GIVE UP  Try it online! INTERCAL is so user-friendly that even something so simple as adding requires a call to the system library in DO (1000) NEXT. I'm working on a more complete answer using only INTERCAL's, uh, "unique", built-in operators. PLEASE NOTE for those trying this program: INTERCAL takes input in numbers with each digit as an English (or Sanskrit, Basque, Tagalog, Classical Nahuatl, Georgian, or Kwakiutl) word, separated by spaces, so ONE ONE inputs 11, DALAWA LIMA inputs 25, and ZAZPI BAT BI inputs 712. A newline separates different inputs, and because of how the parser works, there must be a trailing space at the end of the last input. Numbers are output as Roman Numerals. # NotQuiteThere, 8 bytes 0-- 0- 0  Try it online! Given that one of the aims of this languages was to be unable to perform addition, I think I failed. ## How it works  # Implicit input; 10 and 20 0 # Push 0; STACK = [10 20 0] - # Subtract; STACK = [10 -20] - # Subtract; STACK = [-30] 0 # Push 0; STACK = [-30 0] - # Subtract; STACK = [30] 0 # Push 0; STACK = [30 0] # Output 30;  ## Perl 5, 7 bytes 6 bytes code + 1 for -p. _+=<>  Try it online! (-l added for readability.) # Verbosity, 388 bytes Include<Input> Include<Output> Include<Integer> Include<MetaFunctions> Input:DefineVariable<i; 0> Output:DefineVariable<o; 0> Integer:DefineVariable<f; Input:ReadEvaluatedLineFromInput<i>> Integer:DefineVariable<s; Input:ReadEvaluatedLineFromInput<i>> Integer:DefineVariable<r; Integer:Sum<f; s>> Output:DisplayAsText<o; r> DefineMain<> [ MetaFunctions:ExecuteScript<MetaFunctions@FILE> ]  Try it online! Outputs as Integer<result> (the natural representation of integers in Verbosity) ## Ungolfed Include<Input> Include<Output> Include<Integer> Include<MetaFunctions> Input:DefineVariable<in; 0> Output:DefineVariable<out; 0> Integer:DefineVariable<first; Input:ReadEvaluatedLineFromInput<in>> Integer:DefineVariable<second; Input:ReadEvaluatedLineFromInput<in>> Integer:DefineVariable<result; Integer:Sum<first; second>> Output:DisplayAsText<out; result> DefineMain<> [ MetaFunctions:ExecuteScript<MetaFunctions@FILE> ]  Try it online! ## Wumpus, 5 bytes II+O@  Try it online! ### Explanation Straight-forward and boring: I Read the first integer. I Read the second integer. + Add them. O Output the result. @ Terminate the program.  # Forked, 5 bytes $$+%&


Try it online!

•  - read two integers
• + - add top two stack values
• % - print top of stack as integer
• & - "terminate", prevents the IP from wrapping

# Momema, 9 bytes

-8+*-8*-8


Try it online!

Momema uses prefix syntax, and assignment statements are implicit (simply writing two expressions ab acts as *a = b;), so this program looks like this:

*(-8) = *(-8) + *(-8)


The cell -8 in Momema is memory-mapped for numeric I/O. Reading from it causes input, and writing to it causes output.

print_num(read_num() + read_num())


## Perl6, 3

Standalone function:

*+* 

Complete program (19 bytes):

say [+] slurp.words 

# Pain-Flak, 6 bytes

)}{}{(


Try it online!

Pain-Flak is Brain-Flaks evil twin. When translated into regular brain-flak, we get:

({}{})({}{})


The first one is the standard addition snippet. The second one is effectively a NO-OP.

# JavaScript (Node.js), 18 bytes

a=>eval(a.join+)


Try it online!

# Explanation :

a =>                     // lambda function taking array as input
eval(               // begin eval
a.join+      // joins all elements in a with a + sign in between
)                 // end eval (since this is now a string it gets added up)


# JavaScript (Node.js), 9 bytes

x=>y=>x+y


Try it online!

# Explanation :

x =>                  // lambda taking x as input 1
y =>              // which returns lambda with input y
x + y         // which returns sum of x and y


• Welcome to PPCG! – Martin Ender Apr 12 '18 at 8:37
• Thanks. May I ask what you edited ? – Muhammad Salman Apr 12 '18 at 9:16
• Nvm , found that out. Thanks for the edit. :) – Muhammad Salman Apr 12 '18 at 9:20