Question: Dijkstra created an algorithm for finding the greatest common divisor (GCD) of a number based on the principle that if a number c divides a

 Dijkstra created an algorithm for finding the greatest common divisor (GCD)

Dijkstra created an algorithm for finding the greatest common divisor (GCD) of a number based on the principle that if a number c divides a and b, then it divides a - b. Below is the algorithm in C: int gcd(int m, int n)f if (m--n) else if (m>n) else return m; return gcd(m-n, n); return gcd (m,n-m); Create a subroutine, "gcd", that implements this algorithm. Note that this must be a recursive subroutine Also create a short "main" procedure to test the subroutine. The "main" procedure should prompt the user for two integers (to be typed in using standard input) and should print out the GCD of these numbers

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!