Computers and Technology, 16.10.2020 14:01 Astudent333
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.
Answers: 1
Computers and Technology, 24.06.2019 02:30
Which option completes the explanation for conflict of interest in an organization
Answers: 1
Computers and Technology, 24.06.2019 16:00
Which of the following characters is acceptable to use in a filename? ? / β %
Answers: 1
Computers and Technology, 24.06.2019 21:30
Write an algorithm to check if a number is even or odd and show with flow chart step by step
Answers: 2
Computers and Technology, 25.06.2019 01:00
When a new name is registered on the internet, the process can take two hours to four hours four hours to three days two hours to two days one hour to eight hours
Answers: 1
In this exercise, all integers are considered to be nonnegative, for simplicity. A divisor of an int...
Chemistry, 12.12.2020 16:40
Mathematics, 12.12.2020 16:40
Mathematics, 12.12.2020 16:40
Physics, 12.12.2020 16:40
English, 12.12.2020 16:40
Physics, 12.12.2020 16:40
Biology, 12.12.2020 16:40
Geography, 12.12.2020 16:40
Arts, 12.12.2020 16:40
Mathematics, 12.12.2020 16:40
English, 12.12.2020 16:40