C languageC SolutionChapter 6Programming

Q17 Write a function to compute the greatest common divisor given by Euclid’s algorithm, exemplified for J=1980, K=1617 as follows: Thus, the greatest common divisor is 33.

Program: 138

Write a C function to compute the greatest common divisor given by Euclid’s algorithm, exemplified for J=1980, K=1617 as follows:

1980/1617=1 1980-1*1617=363
1617/363=4 1617-4*363=165
363/165=2 363-2*165=33
5/33=5 165-5*33=0

Thus, the greatest common divisor is 33.

Output:

Enter the value of a: 1980
Enter the value of b: 1617
Greatest Common Divisor of (1980, 1617): 33

Lokesh Kumar

Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.