CSC 273-Data Structures

Assignment #5 - Greatest Common Divisor

Due Wednesday, October 2, 2019

The C expression m % n yields the remainders of m divided by n. Define the greatest common divisor (GCD) of two integers x and y by:
gcd(x, y) = yif (y <= x && x % y == 0)
gcd(x, y) = gcd(y, x)if (x < y)
gcd(x, y) = gcd(y, x % y)otherwise

You will submit a program listing (properly commented) and the output using the following data sets:

xy
328
2415
6448

[Back to the Assignments Page]