The ancient Greek mathematician Euclid developed a method forfinding the greates
ID: 3614731 • Letter: T
Question
The ancient Greek mathematician Euclid developed a method forfinding the greatest common divisor of two integers, a andb. His method is as follows:- If the remainder of a/b is 0 then b is thegreatest common divisor.
- If it is not 0, then find the remainder r ofa/b and assign b to a and the remainderr to b.
- Return to step (A) and repeat the process.
Explanation / Answer
please rate - thanks # include #include int gcd(int,int); int main() { int num1; int num2; printf("Enter the first number "); scanf("%d", &num1); printf("Enter the first number? "); scanf("%d", &num2); printf(" The GCD %d ",gcd(num1,num2 )); getch(); //use this, needs conio to be included return 0; } int gcd(int a, int b) //Euclidsalgorithm {int r; if(b==0) r=a; else {r=a%b; while(r!=0) {a=b; b=r; r=a%b; } } return b; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.