When we learn arithmetic, we always begin with addition. It is, after all, the most elementary operation. We use it to represent natural numbers: 4 is 3 + 1, 2 + 1 + 1, or 1 + 1 + 1 + 1. This representation also helps us understand the first method of addition taught at school. To add two natural numbers A and B, simply take A and add the number 1 to it B times. This is the method we use when we "count on our fingers".
Once we begin working with larger numbers, this method becomes difficult to use, so we learn a second one. To add two large natural numbers A and B, we first add the units digits, then the tens digits, and so on, using a "carry" whenever the result has more than two digits. In fact, this method uses the associative and commutative properties of addition, together with the decomposition of a number into powers of 10. For example, 59 + 125 = (5 × 10 + 9 × 1) + (1 × 100 + 2 × 10 + 5 × 1) = (9 × 1 + 5 × 1) + (5 × 10 + 2 × 10) + 1 × 100. But we would not state these formal properties when explaining to a child how to set out an addition.
Putting the two methods to the test
-----------------------------
If you ask a friend to calculate 23 + 126, you can be sure they will set out the addition rather than use the first method. Clearly, if a and b are "large enough," the second method will be much faster than the first. But does the same hold for a machine, whether a computer or a calculator? We invite you to check that it does by programming both methods in Python on the Graph 90+E calculator. For what follows, let A and B be natural numbers such that A ≤ B.
**The Graph 90+E calculator. Since 31 August 2018, a free update available from
www.casio-education.fr has made it possible to add the new Python programming menu to the calculator**
First method: addition by repeatedly adding one.
To add our two numbers, we take the larger one, here B, and add the integer 1 to it A times (to perform as few iterations as possible).
To calculate 3 + 12, we therefore calculate 12 + 1 = 13, 13 + 1 = 14, and 14 + 1 = 15 in succession. Thus, 3 + 12 = 15. In Python, this gives:
Second method: column addition with carrying.
As a reader of Tangente, you can of course set out an addition with carrying without any difficulty. But if you were asked to explain the method to a child, how would you go about it?
Let's begin with an example. To calculate 127 + 59, here are the steps in detail:
Here, we no longer treat digits as numbers but as symbols, and we apply the following method:
To add A and B, we first add as many zeros as necessary to A so that the two numbers are "the same length," meaning that they have the same number of digits;
We then add the corresponding digits of the two numbers, starting from the right (using method 1), and include a carry if there is one;
We write down the rightmost digit of the result;
If the result has more than two digits, we create a new carry;
We then move on to the adjacent digits;
When there are no digits left, we check whether there is still a carry. If so, we write 1 in front of the result; otherwise, we do nothing;
This gives us the final result.
Let's formalize this second method. Let A = an…a1a0 and
B = bm…b1b0 written in decimal form, where a0, a1… an, and b0, b1… bm are, respectively, the digits of A and B, each lying between 0 and 9.
By assumption, A has no more digits than B. We begin by adding zeros to the left of A so that the two numbers have the same length; A becomes 00…0an…a1a0.
For each i from 0 to m, let di be the units digit of *ai + b*i (that is, the remainder when ai + bi is divided by 10). Then C = cm+1cm…c0 is the sum of A and B, where:
•c0 = d0;
• ci = di + r for i from 0 to m, with r the carry from the previous operation (the quotient when ai–1 + bi–1 is divided by 10);
• cm+1 = r is the final carry.
For this second method, we will implement addition as we would teach it to a child, without using Euclidean division. To write the corresponding program, we begin by converting our numbers into strings (string) using the str function.
We initialize the carry to 0 and create an empty string C.
Using a first for loop, we add the required number of zeros to the beginning of the number with fewer digits, here A, so that both integers have the same length m.
By looping over A[–j–1], B[–j–1], we run through both numbers from right to left (string\_name[–1] returns the last character in the string).
We add the corresponding digits of the two integers using the previous method. But first, we must treat them as numbers again rather than as characters! For this, we use the int function. We then add the previous carry to the result.
We check whether the result has more than two digits. If it does, we create a carry. We then prepend this new result to C.
Finally, we prepend the final carry to the string C and convert this string into a number using the int function.
In Python, this gives:

The hare and the tortoise?
-------------------------
All that remains is to test the calculation speed of the two methods presented! To do so, we define a test function that, for a given two-argument function fct with arguments A and B, calculates fct(A, B) n times, where n is a sufficiently large integer (here, n = 1,000) for a phenomenon to emerge.
In Python, this gives:
Now it is your turn to run a few tests by downloading the "Calculation Speed" program from the CASIO resources section of
www.casio-education.fr/! For example, you can perform the following experiments with the Graph 90+E or your preferred Python development environment:
test(add1, 919, 223, 1000);
test(add2, 919, 223, 1000);
test(add1, 23, 126, 1000);
test(add2, 23, 126, 1000).
You may be in for a few surprises!