krit.club logo

The World of Algorithms - Adding Numbers Digit by Digit

Grade 9CBSE

Review the key concepts, formulae, and examples before starting your quiz.

🔑Concepts

•

An algorithm is a finite sequence of well-defined, computer-implementable instructions to solve a class of problems or perform a computation.

•

The Column Addition Algorithm processes numbers digit by digit starting from the least significant digit (rightmost) to the most significant digit (leftmost).

•

Each number is represented based on its place value: A=dn−110n−1+⋯+d1101+d0100A = d_{n-1}10^{n-1} + \dots + d_1 10^1 + d_0 10^0.

•

Carrying (Regrouping): If the sum of digits at a particular place value is 1010 or more, the 'tens' part of that sum is added to the next higher place value (the column to the left).

•

The Time Complexity of adding two nn-digit numbers is O(n)O(n), meaning the number of steps grows linearly with the number of digits.

📐Formulae

N=∑i=0n−1di×10iN = \sum_{i=0}^{n-1} d_i \times 10^i

si=(ai+bi+ci−1)(mod10)s_i = (a_i + b_i + c_{i-1}) \pmod{10}

ci=⌊ai+bi+ci−110⌋c_i = \lfloor \frac{a_i + b_i + c_{i-1}}{10} \rfloor

💡Examples

Problem 1:

Use the digit-by-digit algorithm to add 8,7458,745 and 6,5826,582.

Solution:

Step 1: Align the numbers by place value. Step 2: Add units: 5+2=75 + 2 = 7. Carry 00. Step 3: Add tens: 4+8=124 + 8 = 12. Write 22, carry 11 to the hundreds place. Step 4: Add hundreds: 7+5+1 (carry)=137 + 5 + 1 \text{ (carry)} = 13. Write 33, carry 11 to the thousands place. Step 5: Add thousands: 8+6+1 (carry)=158 + 6 + 1 \text{ (carry)} = 15.

8745+658215327\begin{array}{r} 8745 \\ + 6582 \\ \hline 15327 \end{array}

The final sum is 15,32715,327.

Explanation:

We start from the right (units). At the tens and hundreds columns, the sum exceeded 99, so we recorded the unit digit and moved the '1' to the next column on the left as a carry.

Problem 2:

Explain the algorithmic steps to add two numbers AA and BB where A=98A = 98 and B=45B = 45.

Solution:

Let a1=9,a0=8a_1=9, a_0=8 and b1=4,b0=5b_1=4, b_0=5.

  1. Calculate sum at 10010^0: 8+5=138 + 5 = 13. s0=13(mod10)=3s_0 = 13 \pmod{10} = 3. c0=⌊13/10⌋=1c_0 = \lfloor 13/10 \rfloor = 1.

  2. Calculate sum at 10110^1: 9+4+c0=9+4+1=149 + 4 + c_0 = 9 + 4 + 1 = 14. s1=14(mod10)=4s_1 = 14 \pmod{10} = 4. c1=⌊14/10⌋=1c_1 = \lfloor 14/10 \rfloor = 1.

  3. Result is formed by digits c1,s1,s0c_1, s_1, s_0: 1,4,31, 4, 3.

98+45143\begin{array}{r} 98 \\ + 45 \\ \hline 143 \end{array}

Explanation:

This demonstrates the mathematical logic of the carry cic_i and the sum digit sis_i used in computer science to implement addition.

Adding Numbers Digit by Digit Class 9 Notes & Examples