Question: Consider the algorithm: Algorithm Input: A natural number m and a natural number n ( 1 ) if n < m then return n (

Consider the algorithm:
Algorithm
Input: A natural number m and a natural number n
(1) if n < m then return n
(2) repeat
(a) let n := n m,
(3) until n < m
(4) return n
What does the algorithm return when the input is n :=2 and m :=2?
What does the algorithm return when the input is n :=4 and m :=2?
What does the algorithm return when the input is n :=4 and m :=2?
What does the algorithm return when the input is n :=19 and m :=2?
What does the algorithm compute ?
A. m n
B. The difference of the sum of the first n natural numbers and m.
C.(m)n
D. The quotient of the division of n by m.
E. The remainder of the division of n by m.
F.n + m
G. The greatest common divisor of m and n

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!