Computers and Technology

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.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:10, Tatertotzzzz
Write a method that accepts a string object as an argument and returns the number of words it contains. for instance, if the argument is "four score and seven years ago", the method should return the number 6. demonstrate the method in a program that asks the user to input a string and then passes that string into the method, printing out whatever the method returns.
Answers: 3
image
Computers and Technology, 22.06.2019 01:00, keasiabradley
Search the web for two examples of digital art that you like. the examples must be from different mediums (example: one digital photo and one computer animation not two computer animations). compose an essay for each example you choose about why the piece appeals to you, and identify the medium used.
Answers: 1
image
Computers and Technology, 22.06.2019 20:00, BreadOfTheBear
What statement best describes operating systems? it’s possible for modern computers to function without operating systems. most operating systems are free or very inexpensive. operating systems are managed by the computer’s microprocessor (cpu). operating systems manage the computer’s random access memory (ram).
Answers: 1
image
Computers and Technology, 23.06.2019 01:30, bri2728
Jason works as an accountant in a department store. he needs to keep a daily record of all the invoices issued by the store. which file naming convention would him the most? a)give the file a unique name b)name the file in yymmdd format c)use descriptive name while naming the files d)use capital letters while naming the file
Answers: 3
Do you know the correct answer?
The greatest common divisor (gcd) of two positive integers is the largest integer that divides evenl...

Questions in other subjects:

Konu
Mathematics, 29.12.2020 01:00
Konu
English, 29.12.2020 01:00
Konu
Mathematics, 29.12.2020 01:00