Euclid's algorithm to find hcf or gcd of two numbers.

1. Start.

2. Read num1 and num2.

3. If num1 < num2,
      Swap values of num1 and num2
       Refer : Swap using third variable
             or, Swap without using third variable

4. While (num1 % num2) != 0 
           num1 = num2;
           num2 = num1 % num2;

5. num2 is the gcd.

6. End.

No comments:

Post a Comment