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

• 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

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

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

# 6502 machine code - 8 bytes

A5 08 65 09 85 0A 4C 06

Input stored at 0x08 and 0x09, output storad at 0x0A

# Unnamed, 25 Bytes

Takes 2 numbers from the input area, then adds them together and prints it to the output area.

Try it (paste the code to the leftmost textarea, write the numbers you want to print to the middle textarea in two separate lines, like 5 and 4 in two different lines, and press run)

, # >1 # , # _+.@0.@1 # .

## How?

" # " is the command separator. I will explain the others.

,                       /take one input as integer. store it at the current pointer (initially 0)
>1                     /move the pointer by 1 cell to the right (now is 1)
,                    /take one input as integer and store it at the current pointer, now 1
_                   /assign                                     to cell 1
+.                 /      the sum of
@0.@1             /                the numbers at cell 0 and 1
.            /print the value in the current pointer (which is 1)
• is the language complete / Is it a stable version ? – Muhammad Salman Jun 3 '18 at 8:56
• it is stable except the documentation (I am way too lazy to write the docs) – Windmill Cookies Jun 3 '18 at 8:58
• Then I highly suggest that you have it added to TIO. You can go here. I suggest that you ping Dennis. – Muhammad Salman Jun 3 '18 at 9:16
• no, thanks, I am working on much better languages. I will have them added to tio when I finish them, but not unnamed. unnamed was just like a fun side project of mine, and i was a really bad programmer when I wrote it (I am still very bad, but a little better) – Windmill Cookies Jun 3 '18 at 9:26

# 7, 8 bytes, 22 characters

1717023740344172360303

Try it online!

This program is encoded on disk as (xxd hexdump):

00000000: 3cf0 9f81 c87a 7830                      <....zx0

7 doesn't really support numbers natively, and thus it's hard to define what a number is for the purpose of a function submission. As such, this is a full program, reading from stdin, outputting to stdout (which explains where much of the length comes from).

This program doesn't support negative numbers, because 7 can't input those using numeric I/O (although it can output them). As such, supporting negative numbers would require the use of character input (and a decimal→integer parser), which would make the program much, much more complex.

## Explanation

1717023740344172360303
7 7   7                Stack element separators
1 1 023                 Initial stack
40344172360303  Initial program (also stored on the stack)
(Implicit: run the initial program, but leave it on the stack)
4               Swap with blank element between
0              Escape top stack element, append it to element below

So at this point, we've effectively swapped the program below the 023 element, escaping that element in the process. The 023 is a program in a domain-specific I/O language; and putting the program as the second stack element means that we can discard it (the second stack element is the only one that can be discarded).

3             Do I/O using top element, discard second element
0                   Set I/O format: numeric in decimal
23                 Input via repeating the third stack element

We now have only two stack elements; 1 at the bottom, and the first input in unary just above it (because we repeated the second-last stack element, which was 1, and thus will have a number of 1s).

4            Swap with blank element between
4           Swap with blank element between
172360     Append an escaped representation of "23" to TOS
3    Do I/O using top element, discard second element
23       Input via repeating the third stack element

So now our stack consists of the first input (in unary) directly below the second stack element (in unary).

0   Escape top element, appending it to the element below
3  Do I/O using top element, and exit

The 3 command exits the program as we're out of stack, but not before it outputs the number we calculated. The number in question will consist of a number of 7s equal to the first number input, followed by a number of 1s equal to the second number input (these are the unescaped and escaped representations of the same command). Numeric I/O treats 1 and 7 as equivalent, and having a value of +1; thus, the unary number gets translated into decimal and output.

## Burlesque - 4 bytes

ps++

ps   parse
++ sum
• How does this work? Can you link to an interactive demo and / or provide instructions on how to execute it? – Οurous Nov 18 '18 at 21:57
• ps parses the input into a list and ++ computes the sum of a list. I added a link to the online interpreter. – mroman Nov 18 '18 at 22:10

# Aheui (esotope), 15 bytes(5 characters)

방방다망히

Try it online!

Meet Aheui(아희), A Korean alphabet-based esoteric programming language.

# Re:direction, 9 characters, 3 bytes

♦►
♦►
◄ ▼

Try it online!

In Re:direction's packed encoding:

F1 F1 B6

(Byte F1 encodes ♦►␤; B6 encodes ◄ ▼).

## Explanation

Re:direction is a 2D language that uses a queue of direction commands. At the start of the program, the queue is initialized from user input; an integer n becomes n copies of , then . From that point onwards, whenever we use a direction command, it controls the direction in which the instruction pointer moves but also gets pushed onto the tail of the queue.

The command shifts one direction from that queue, and moves in that direction. So ♦► is effectively a loop that moves any number of from the head of the queue to the tail; as long as the queue starts with , we'll shift it and go right, and hit the in the program, which sends the IP right back where it started (wrapping around the edge of the program) and pushes the to the tail of the queue instead. Once we hit the , it gets deleted from the queue and we move onwards.

We can note that ♦► does not preserve the in the queue. As such, running it twice deletes both from the initial queue, leaving us with a number of equal to the sum of the initial two numbers.

We need to encode the output the same way as the input, meaning that we need to add a and halt the program. A direction command that points to itself will run and then immediately halt the program, so we can use a on a column by itself to do both jobs. We do, however, need to get there; this program uses a to do so (because stray ups and lefts in the queue won't affect the output).

# RUST, 29 bytes

Save 5 bytes thank to ASCII-only

Try this on line

fn s(a:i32,b:i32)->i32{a+b}

ASCII-only also beat my solution here

• 8, also you have unneeded spaces anyway – ASCII-only Jan 29 '19 at 7:48
• @ASCII-only Thank you a lot for your solution. – chau giang Jan 29 '19 at 8:00
• You forgot to rename the function – ASCII-only Jan 29 '19 at 8:02
• lol, now it's 27 bytes not 29 – ASCII-only Jan 29 '19 at 8:10
• @ASCII-only, thank you, I just updated it, I count all bytes with my eyes so maybe I was wrong – chau giang Jan 29 '19 at 8:12

# Clam, 4 bytes

p+rr

Try it online!

Explanation

p               print ...
+               the sum of ...
r               the first line of STDIN and ...
r               the second line of STDIN

# Whitespace, 36 bytes

[S S S N
_Push_0][S N
S _Duplicate][T N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve][S S S N
_Push_0][S N
S _Duplicate][T N
S T _Print_as_integer]

Letters S (space), T (tab), and N (new-line) added as highlighting only.

Try it online (with raw spaces, tabs, and newlines only).

Explanation:

When a number is read from STDIN it stores it in the heap-address specified at the top of the stack, and then the Retrieve function can be used to get it later on. So to read a number from STDIN you'll need the following sub-steps:

1. Put a number on the stack:
• S at the start: Enable Stack Manipulation
• S: Push what follows as number to the top of the stack
• S/T: Positive or negative number
• Some S and/or T followed by a N: Number as binary, where S=0 and T=1.
2. Duplicate this number:
• S at the start: Enable Stack Manipulation
• NS: Duplicate the top value on the stack
3. Read a number from STDIN, and store it in the heap-address specified at the top of the stack:
• TN at the start: Enable I/O
• TT: Read a number, and place it in the heap specified at the top of the stack
4. Retrieve this number from the heap
• TT at the start: Enable Heap Access
• T: Retrieve a value from the heap with the given heap-address at the top of the stack

So here is every step of the full program above:

Command    Explanation              Stack      Heap     STDIN    STDOUT    STDERR

SSSN       Push 0                   [0]        {}
SNS        Duplicate top (0)        [0,0]      {}
TNTT       Read STDIN as integer    [0]        {0:-3}   -3
TTT        Retrieve heap (at 0)     [-3]       {0:-3}
SSSN       Push 0                   [-3,0]     {0:-3}
SNS        Duplicate top (0)        [-3,0,0]   {0:-3}
TNTT       Read STDIN as integer    [-3,0]     {0:5}    5
TTT        Retrieve heap (at 0)     [-3,5]     {0:5}
TSSS       Add top two              [2]        {0:5}
TNST       Print top as integer     []         {0:5}            2
Exit with error

Unfortunately the heap-address cannot be negative, otherwise the second SSSN (Push 0) could have been golfed to SNS (duplicate first STDIN input as heap-address).

# Seed, 11 bytes

4 141745954

Damn, It's quite small

• This appears to correspond with the program &&+., which loops infinitely outputting zeroes. You need an @ afterwards – Jo King Jan 7 at 23:45

# Re:direction, 9 bytes

▲♦▼
►♦
▲

Suprisingly small for a language like this. Re:direction is a language that only uses arrows, a queue, and to go in the direction of the first item on the queue

# Explanation

Note: I'll be using .'s to represent instructions I'm not talking about, and I'll split it up into a couple of sections

Input is automatically pushed to the queue as ►'s seperated by ▼'s

▲..
►.      Pushes ▲ into the queue, used as a marker later
.

...
►♦       Loop that goes through every item of the queue (the input). If its ►, it does nothing to it.
▲       If it is ▼, it gets replaced by ▲, which is ignored by the output

.♦▼      If it is an ▲, another ♦ is run, which goes right and removes one item from the queue to make the output correct
.♦       Then, since the ▼ is the only arrow in it's column, it gets pushed to the queue then the program halts
.

Try it online!

#&
+

Pretty self explanatory, uses wrapping so there is only 1 input instruction

Try it online!

# Plumber, 244 bytes

[]                []
[][=[]
[[=[][]  [][]  ][]][=
][[]  ][[=]]]][]=[[]
[]===][]  ][===][]
][][  []    ][  ]     [][]
[     ][]=][[[===][[
][]]]=][[]=[=]=]=]]==]=]][
][=]=]]==]=][]  ][
[][=][=[[][[=]][
==]=]][[=[= =

I thought I had a good solution for a while...except it didn't work with 0 or 1 as the first input. This program consists of three parts: incrementer, decrementer, and outputter.

The decrementer is on the left, and holds the first value. It is incremented, since a 0 would cause an infinite loop (as the program tries to decrement to 0 and gets a negative value). It will decrement the stored value at execution, and send a packet to the incrementer.

The incrementer is on the right, and stores the second input. When the decrementer sends a packet, it increments its stored value, and sends a packet back to the decrementer.

Whenever the decrementer sends the packet to the incrementer, it is checked by the outputter. If the packet is 0, execution stops and the value of the incrementer is read and outputted. It uses a NOT gate, one of the most complicated parts of the program.

## Old design (doesn't work with some inputs), 233 bytes

[]          []
[][]  [][]  =][]
[]=][]=][[=]][
[][===][  [][===[]
[][]   [        []    ][][
] [===][=]][     ]
][[=[=[=[=[=]=[]][=[[[][
][[=[=[=[==[[=[=][
[]]=][=][]
= =]=]][[=[==

The new one is flipped to save bytes, and it's really confusing me. This design is the one I worked with for a week or so when designing the interpreter.

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

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

# SystemVerilog (HDL) (93 chars)

Here's a pretty simple 8-bit full adder implementation (including input carry for chaining).

module a(input[7:0] a,input[7:0] b,input d,output c,output[8:0] f);
assign f=a+b+d;
endmodule

Inputs: [7:0]a and b, carry bit d.

Outputs: [8:0]f. The top bit can be used as a carry output signal.

hh+
h   Take input
h  Take input
+ Get the sum

# C, 25 Bytes

p(a,b){printf("%d",a+b);}

Usage

p(a,b){printf("%d",a+b);}
main(c,v)char**v;{p(atoi(*++v),atoi(*++v));}

Or, if you want a full program: (+29 chars)

main(c,v)char**v;{printf("%d",atoi(*++v)+atoi(*++v));}

Take 2 arguments and outputs the results in STDOUT

• You dont need to print it, a simple return will suffice. – Karl Napf Oct 27 '16 at 15:22

+

Usage:

> +(1,2)
3

Sample run:

Sample run:

21

# SQF, 19

Using the function-as-a-file format:

params["x","y"];x+y

Call as: [X, Y] call NAME_OF_COMPILED_FUNCTION

# S.I.L.O.S 38

a = i
a + i
printInt a

For documentation see the repo https://github.com/rjhunjhunwala/S.I.L.O.S Fee free to try this code online!

• Perhaps you meant printInt instead of prinInt – Leaky Nun Aug 26 '16 at 15:29
• How does it work? – Leaky Nun Aug 26 '16 at 15:39
• @LeakyNun whoopsmy bad, fixing now – Rohan Jhunjhunwala Aug 26 '16 at 16:16
• 2 bytes off – Leaky Nun Aug 26 '16 at 16:20
• @LeakyNun thanks, you showed me a feature I didn't even know my language had! I though readIO must have a prompt after it! – Rohan Jhunjhunwala Aug 26 '16 at 16:21

# Batch, 52 Bytes

set/p x=
set/p y=
set/a z=%x%+%y%
echo %z%
pause>nul

This is the lowest byte number you will have while still making the program work. I did the challenge by making a program, not just what the operation was. This method will allow you to input any number and then any other number, including negatives, and the program will output a number.

• Is this a full program? I don't know batch but it looks like the numbers get inputted by editing the program rather than a prompt of some kind – Blue Jul 6 '16 at 16:32
• Hey Nitrate. Welcome to PPCG. A few problems with this post: this is code-golf, which means you need to shorten your code to as short as possible. You don't have to take input like this - you could possibly take it as command line arguments to shorten it. Nice to see you here, m9. – Addison Crump Jul 6 '16 at 22:44
• @muddyfish The /p switch allows you to set a variable equal to a line of input entered by the user. – Dennis Oct 18 '16 at 15:36

## RubyGolf, 15 bytes

p gets.i+gets.i

code is so short it hit the character limit. ugh.

New language created by me, interpreter going up soon. non competing.

## Y, 5 bytes

{α+β}

Anonymous function returning the sum of it first and second argument.

# JavaScript, 27 bytes

function s(a,b){return a+b}

I thought this needed a semi-colon after the return statement, but when typing it into the Chrome Console, it works fine without.

• a=>b=>a+b, but then it will be a duplicate – TuxCrafting Oct 27 '16 at 18:27
• Also (a,b)=>a+b is better, but still, duplicate – Yotam Salmon Oct 30 '16 at 21:27