krit.club logo

The World of Algorithms - Adding Numbers

Grade 9CBSE

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

🔑Concepts

•

An algorithm is a step-by-step procedure or a set of rules to be followed in calculations or other problem-solving operations. For adding numbers, the algorithm must handle inputs, processing (addition), and output.

•

The basic addition algorithm for two numbers aa and bb follows these steps: 1. Start, 2. Input a,ba, b, 3. Calculate S=a+bS = a + b, 4. Display SS, 5. End.

•

For multi-digit addition, the algorithm uses the concept of 'place value' and 'carry'. We start from the rightmost digit (units place) and move to the left.

•

When adding nn numbers x1,x2,...,xnx_1, x_2, ..., x_n, the algorithm uses an accumulator variable (usually initialized to 00) and updates it iteratively: Sum=Sum+xiSum = Sum + x_i.

•

In computational terms, the complexity of adding two numbers with dd digits is O(d)O(d), as each pair of digits is processed once.

📐Formulae

S=a+bS = a + b

Sum=∑i=1nxi=x1+x2+⋯+xnSum = \sum_{i=1}^{n} x_i = x_1 + x_2 + \dots + x_n

Average=∑i=1nxin\text{Average} = \frac{\sum_{i=1}^{n} x_i}{n}

0+0=00 + 0 = 0

0+1=10 + 1 = 1

1+1=10 (in binary, which is 0 with a carry of 1)1 + 1 = 10 \text{ (in binary, which is 0 with a carry of 1)}

💡Examples

Problem 1:

Use the column addition algorithm to find the sum of 85748574 and 63926392.

Solution:

We align the numbers by their place values and add from right to left, carrying over values as needed. 11108574+639214966\begin{array}{r} 111\phantom{0} \\ 8574 \\ + 6392 \\ \hline 14966 \end{array} Where the small 11s represent the carry values transferred to the next column.

Explanation:

Step 1: Add units 4+2=64 + 2 = 6. Step 2: Add tens 7+9=167 + 9 = 16 (Write 66, carry 11). Step 3: Add hundreds 5+3+1 (carry)=95 + 3 + 1 \text{ (carry)} = 9. Step 4: Add thousands 8+6=148 + 6 = 14.

Problem 2:

Define an algorithm to calculate the sum of the first nn natural numbers.

Solution:

The iterative algorithm is:

  1. Start
  2. Input the value of nn
  3. Initialize S=0S = 0 and i=1i = 1
  4. While i≤ni \le n: S=S+iS = S + i i=i+1i = i + 1
  5. Output SS
  6. Stop Alternatively, we can use the mathematical formula: S=n(n+1)2S = \frac{n(n + 1)}{2}

Explanation:

The iterative approach adds each number one by one to a running total. The formulaic approach is a constant-time algorithm O(1)O(1) which is much faster for large nn.

Problem 3:

Calculate the sum of Rs1250Rs 1250 and Rs450Rs 450 using the addition algorithm.

Solution:

Placing the numbers in the vertical addition format: 1250+4501700\begin{array}{r} 1250 \\ + 450 \\ \hline 1700 \end{array} The sum is Rs 1700.

Explanation:

Units: 0+0=00 + 0 = 0. Tens: 5+5=105 + 5 = 10 (write 00, carry 11). Hundreds: 2+4+1 (carry)=72 + 4 + 1 \text{ (carry)} = 7. Thousands: 1+0=11 + 0 = 1.