Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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:
  1. If the remainder of a/b is 0 then b is thegreatest common divisor.
  2. If it is not 0, then find the remainder r ofa/b and assign b to a and the remainderr to b.
  3. Return to step (A) and repeat the process.
Write a program called gcd.c that takes a andb as inputs from the user and uses a function to performEuclid's procedure. Display a and b and thegreatest common divisor

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; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote