The greatest common factor of two nonnegative integers x and y is the largest integer that is a factor of both x and y. Calling this function gcf(x, y), you would expect to find that gcf(14,49) = 7 and gcf(25,50) = 25.

We defined the greatest common factor function in class. The definition employs the following facts.

  1. gcf(0,y) = y
  2. gcf(x,y) = gcf(y `mod` x, x) (as long as x is not 0).
Write the definition of gcf and test it by pushing the Compute button. After it works, submit it by pushing the Submit button.

 

  [Language: Cinnameg  Kind: function definition]