subject

The greatest common divisor (gcd) of two positive integers is the largest integer that divides evenly into both of them. for example, the gcd (102, 68) = 34. we can efficiently compute the gcd using the following property, which holds for positive integers p and q: if p > q, the gcd of p and q is the same as the gcd of q and p % q. in euclid's algorithm, we start with two numbers x and y. if y is zero then greatest common divisor of both will be x, but if y is not zero then we assign the y to x and y becomes x%y. once again we check if y is zero, if yes then we have our greatest common divisor or gcd otherwise we keep continue like this until y becomes zero. since we are using modulo operator, the number is getting smaller and smaller at each iteration, so the x%y will eventually become zero. let' take an example of calculating gcd of 54 and 24 using euclid's algorithm. here x = 54 and y = 24, since y is not zero we move to the logical part and assign x y, which means x becomes 24 and y becomes 54%24 i. e. 6. since y is still not zero, we again apply the logic. this times x will become 6 and y will become 24%6 i. e. y = 0 bingo, y is now zero which means we have our answer and it's nothing but the value of x which is 6 (six). write a recursive java program to calculate the gcd by euclid's method.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 07:10
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
question
Computers and Technology, 23.06.2019 10:50
The volume v and paper surface area a of a conical paper cup are given by where r is the radius of the base of the cone and h is the height of the cone. a. by eliminating h, obtain the expression for a as a function of r and v. b. create a user-de ned function that accepts r as the only argument and computes a for a given value of v. declare v to be global within the function. c. for v ! 10 in.3 , use the function with the fminbnd function to compute the value of r that minimizes the area a. what is the corresponding value of the height h? investigate the sensitivity of the solution by plotting v versus r. how much can r vary about its optimal value before the area increases 10 percent above its minimum value?
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
The processing of data in a computer involves the interplay between its various hardware components.
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
Freya realizes she does not have enough in her bank account to use the debit card. she decides to use a credit card instead. which questions should freya answer before using a credit card? check all that apply. can i pay at least the minimum payment each month? can i make payments on time and avoid late fees? will i have to take out a loan? how much in finance charges can i afford to pay? should i talk to a consumer credit counseling service?
Answers: 1
You know the right answer?
The greatest common divisor (gcd) of two positive integers is the largest integer that divides evenl...
Questions
question
Physics, 01.12.2020 02:30
question
English, 01.12.2020 02:30
Questions on the website: 13722361