![tatia65](/avatars/32835.jpg)
tatia65
20.09.2020 •
Computers and Technology
The greatest common divisor (GCD) of two integers a and b is defined as the largest integer that can divide both a and b without a remainder. For example, the GCD of 30 and 54 is 6, whereas the GCD of 7 and 5 is 1. The following procedure was developed by Euclid to compute the greatest common divisor of two positive integers a and b. In this exercise, we will prove the correctness of this algorithm. procedure Euclidean(a, b) 1 x ← a 2 y ← b 3 while x 6= y do 4 if x > y then 5 x ← x − y 6 else 7 y ← y − x 8 return x
(a) State the loop invariant for the while loop in this procedure.
(b) Prove the loop invariant.
(c) Prove that procedure Euclidean always terminates provided that a and b are positive integers.
(d) Using the termination property of your loop invariant, prove that procedure Euclidean computes and returns the greatest common divisor of a and b.
Solved
Show answers
More tips
- F Family and Home Why Having Pets at Home is Good for Your Health...
- H Health and Medicine How to perform artificial respiration?...
- H Health and Medicine 10 Tips for Avoiding Vitamin Deficiency...
- F Food and Cooking How to Properly Cook Buckwheat?...
- F Food and Cooking How Many Grams Are In a Tablespoon?...
- L Leisure and Entertainment Carving: History and Techniques for Creating Vegetable and Fruit Decorations...
- P Photography and Videography How to Choose the Perfect Photo Paper for Your Images?...
- H Health and Medicine What vaccines do children need?...
- H Health and Medicine Reasons for the Appearance of Warts: Everything You Need to Know...
- A Art and Culture How to Learn Screaming: Step-by-Step Guide for Beginners...
Answers on questions: Computers and Technology
- C Computers and Technology 6. what is the difference between portrait and landscape orientation? what are the advantages of each?...
- C Computers and Technology What makes a good design...
- C Computers and Technology 1. For each of the following schedules, decide whether it is an unrecoverable, recoverable, cascadeless or strict schedule. If a schedule fits several of the categories, then specify...
- C Computers and Technology Select the true statement below. Using tables can improve your search engine optimization. Content contained within Flash media is invisible to search engines. Your HTML code must...
- C Computers and Technology Change the slide layout from the ....
- M Mathematics The equations ax + by = c and dx -by = e form a system of equations where a, b, c, d, and e are real numbers with a -d. Solve the system for x. please help! it’s for an assignment...
- M Mathematics Contribe 9. Jose bought 7 packets of tomato seeds. Each packet contained 20 seeds. She planted 1 packet of the seeds, and 12 seeds sprouted. What is the probability that the seeds...
- G Geography What is the volume of the Outer Core only?...
- M Mathematics Pls help meeeeeeeeeee...
- C Chemistry If you have carbon dioxide at 1.0 atm and 25°C, could you make it a liquid by cooling it down? How could you make it a liquid at 25°c? If you increase the pressure of carbon dioxide...
Ответ:
the answer for plato is a