subject

In this exercise, all integers are considered to be nonnegative, for simplicity. A divisor of an integer k is any integer d ≠ 0 such that k/d has no remainder. A common divisor for a set of integers is an integer that is a divisor for each integer in the set. Euclid’s algorithm for finding the greatest common divisor (GCD) of two nonnegative integers, m and n, can be written as follows:

1: procedure gcd(int m, int n)
2: if n = 0 then
3: answer ← m
4: else if m < n then
5: answer ← gcd(n, m)
6: else
7: r ← m - n ⋅ ⌊m/n⌋ //r is the remainder of mn
8: answer ← gcd(n, r)
9: end if
10: return ← anwser
11: end procedure

The preconditions for gcd(m, n) are that m ≥ 0, n ≥ 0 and m + n > 0.

Prove the following using induction:

a. If the preconditions of gcd(m, n) are satisfied, then the value that the function returns is some common divisor of m and n.
b. If the preconditions of gcd(m, n) are satisfied, then the value that the function returns is the greatest common divisor of m and n.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 21:00
In this lab, you add a loop and the statements that make up the loop body to a c++ program that is provided. when completed, the program should calculate two totals: the number of left-handed people and the number of right-handed people in your class. your loop should execute until the user enters the character x instead of l for left-handed or r for right-handed. the inputs for this program are as follows: r, r, r, l, l, l, r, l, r, r, l, x variables have been declared for you, and the input and output statements have been written.
Answers: 3
question
Computers and Technology, 22.06.2019 02:00
Consider how gaming consoles initially relied on joysticks and joypads and then made the switch to modern gaming controls, which include analog sticks, buttons and switches, touch controls, accelerometers, motion controls, etc. name at least two kinds of gaming experiences that are possible with these new control devices but were not possible on original joysticks. explain how new technologies made this newer game style possible.
Answers: 1
question
Computers and Technology, 22.06.2019 05:30
Gerard is currently working as an entry-level customer support technician, but he would like to someday become a software developer. what is the best first step to understand what he should do? ask his manager for a new job or at least a job recommendation study graphic design in order to obtain the necessary skills use career resources to investigate what skills and education are required work part-time as an entry-level web developer question 13 (true/false worth 6 points) (08.03 lc) career resources are used to explore career options and find career information. true false question 14(multiple choice worth 6 points) (08.01 mc) classify the following skills: writing html code, evaluating color theory, using design principles. hard skills interpersonal skills people skills soft skills question 15 (true/false worth 6 points) (08.03 lc) a mentor is a person who is advised, trained, or counseled by a trusted mentee. true false
Answers: 2
question
Computers and Technology, 22.06.2019 10:00
What is a society that has moved to the internet rather than relying on physical media called
Answers: 2
You know the right answer?
In this exercise, all integers are considered to be nonnegative, for simplicity. A divisor of an int...
Questions
question
Mathematics, 24.03.2020 23:32
Questions on the website: 13722362