# What is an algorithm?

Question:

What is an algorithm?

Solution:

Algorithm is a step-by-step procedure for calculations.

For example:

Euclid's Division Algorithm: In order to compute the HCF of two positive integers say $a$ and $b$, with $a>b$ by using Euclid's algorithm, we follow the following steps:

$\underline{\text { STEP I }}$ : Apply Euclid's Division Lemma to $a$ and $b$ and obtain whole numbers $q_{1}$ and $r_{1}$, such that $a=b q_{1}+r_{1}, 0 \leq r_{1}$\underline{\text { STEP II: If }} r_{1}=0, b$is the HCF of$a$and$b$. STEP III: If$r_{1} \neq 0$, apply Euclid's division lemma to$b$and$r_{1}$and obtain whole numbers$q_{1}$and$r_{2}$, such that$b=q_{1} r_{1}+r_{2}$STEP IV: If$r_{2}=0$, then$r_{1}$is the HCF of$a$and$b$.$\underline{\text { STEP V: }}$If$r_{2} \neq 0$, then apply Euclid's division lemma to$r_{1}$and$r_{2}$and continue the above process till the remainder$r_{n}$is zero. The divisor at this stage i.e;$r_{n-1}$, or the non-zero remainder at the previous stage is the HCF of$a$and$b\$.