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

C++ programming I need help creating a formula for the Euclidean algorithm,which

ID: 3609699 • Letter: C

Question

C++ programming I need help creating a formula for the Euclidean algorithm,which will find the greatest common divisor for a fractiona/b. Given two natural numbers, a and b,
  1. check if b is zero; if yes, a is the gcd
  2. if not, let r = a modulus b,
  3. a = b, b = r
  4. repeat steps 2 and 3 until r is 0
  5. when r is 0, b will be the GCD
Example: to find the GCD of 72 and42
    let a = 42 and b = 72
    r = 42 modulus 72 = 42
    r = 72 modulus 42 = 30
    r = 42 modulus 30 = 12
    r = 30 modulus 12 = 6
    r = 12 modulus 6 = 0
    since the r is 0, 6 is the GCD I am extremely confused on how to to this C++ programming I need help creating a formula for the Euclidean algorithm,which will find the greatest common divisor for a fractiona/b. Given two natural numbers, a and b,
  1. check if b is zero; if yes, a is the gcd
  2. if not, let r = a modulus b,
  3. a = b, b = r
  4. repeat steps 2 and 3 until r is 0
  5. when r is 0, b will be the GCD
Example: to find the GCD of 72 and42
    let a = 42 and b = 72
    r = 42 modulus 72 = 42
    r = 72 modulus 42 = 30
    r = 42 modulus 30 = 12
    r = 30 modulus 12 = 6
    r = 12 modulus 6 = 0
    since the r is 0, 6 is the GCD I am extremely confused on how to to this

Explanation / Answer

please rate - thanks # include int main() {    int a,b,r;            couta;    coutb;    if(b==0)        r=a;    else        {r=a%b;        while(r!=0)           {a=b;           b=r;           r=a%b;           }        }    cout
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