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, 22.06.2019 11:30
Hassan is writing his master’s thesis, which is a thirty-page document. he received some feedback from his professor in the form of comments, but does not see where the comments are. what is the fastest way for hassan to find the feedback?
Answers: 3
question
Computers and Technology, 22.06.2019 15:30
Which of the following examples has four beats in each measure?
Answers: 2
question
Computers and Technology, 22.06.2019 19:10
What a backup plan that you have created in a event you encounter a situation
Answers: 2
question
Computers and Technology, 23.06.2019 07:50
Apython programming question: assume s is a string of lower case characters. write a program that prints the number of times the string 'bob' occurs in s. for example, if s = 'azcbobobegghakl', then your program should print number of times bob occurs is: 2
Answers: 3
You know the right answer?
The greatest common divisor (gcd) of two positive integers is the largest integer that divides evenl...
Questions
question
Advanced Placement (AP), 09.01.2021 01:00
question
Mathematics, 09.01.2021 01:00
question
Chemistry, 09.01.2021 01:00
Questions on the website: 13722363