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 03:40
Hello my name is mihai and i need your : )i have to do a python project in computer science and i’m really busy with my mocks this period of time besides this i’m not good at coding so could someone pls pls pls sort me out ? i actually beg ; ))
Answers: 1
question
Computers and Technology, 22.06.2019 11:00
When working with a team you should always do the following, except? question 3 options: be dependable and trustworthy be sensitive to others feelings do your fair share critique members of the group
Answers: 2
question
Computers and Technology, 22.06.2019 22:00
During physical science class ben and jerry connected three identical lightbulbs in parallel to a battery where happens when ben removes one of the lightbulbs from it’s socket
Answers: 2
question
Computers and Technology, 23.06.2019 07:30
To check spelling errors in a document, the word application uses the to determine appropriate spelling. internet built-in dictionary user-defined words other text in the document
Answers: 2
You know the right answer?
The greatest common divisor (gcd) of two positive integers is the largest integer that divides evenl...
Questions
question
Mathematics, 07.10.2020 07:01
question
Physics, 07.10.2020 07:01