You are not logged in.
Example of adding two numbers a and b with the result s:
c 101
a 404
b 678
s 1082
Here, c stands for "carry"(2).
The general schema for adding two non-negative integers(1) a and b looks like this:
Below, we shall benefit from the definition of x modulo 10(4):
x mod 10 = x1
and from the definition of x // 10:
x // 10 = (x - x1) / 10
where x stands for a non-negative integer(1) with x1 as its least significant digit.
We note that:
x mod 10 picks out the least significant digit of x
x // 10 shifts the digits of x one position to the right and discards the digit to the right of the decimal point
Let n be a natural number(1).
Let the non-negative integers(1) c, a, b, and s be represented by their sequences(5) of digits(3):
The number of digits is set to n for both a and b.
If one of a and b should at the outset have less than n number of digits, its number of digits is increased by extending its sequence of digits to the left with digits equal to 0 until its number of digits equals n.
According to the general schema for adding two non-negative integers, we define the digits of c like this:
Then:
We take a closer look at s:
Let n be a natural number(1).
Let x be a non-negative integer(1) represented by its sequence(5) of digits(3):
Then:
We have:
References:
(1) Natural number (non-negative integers) https://en.wikipedia.org/wiki/Natural_number
(2) Carry (arithmetic) https://en.wikipedia.org/wiki/Carry_(arithmetic)
(3) Numerical digit https://en.wikipedia.org/wiki/Numerical_digit
(4) Modulo Operation https://www.mathsisfun.com/numbers/modulo.html
(5) Sequences https://www.mathsisfun.com/algebra/sequences-series.html
I majored in Physics in 1976. Also, I studied mathematics and computer science. I worked as a computer programmer. I became a pensioner in 2016. I am from Norway.
Offline