Write a c program to compute GCD of two positive numbers?

The largest positive integer which divides two or more integers without any remainder is called Greatest Common Divisor. greatest common divisor of two positive numbers by Euclid’s Algorithm: let m and n be two positive integers then below is the steps to compute gcd.

Let m=20 and n=298
m = 2*2*5
n = 2*149

Here 2 is largest common digit which divides both m and n , so 2 is gcd of 20 and 298.

Here is sample code in c++.

Recursive solution of c program to compute gcd of two positive numbers


Related Contents to follow