answersLogoWhite

0


Best Answer

algorithm GCD (a, b) is:
while (a <> b) do
if a > b then a := a - b else b := b - a
end while
return a

User Avatar

Wiki User

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

7y ago

You can use the Euclidian algorithm for this. This can be expressed very succinctly with recursion:gcd(a, b):

if b == 0 return a

else return gcd(b, a%b)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a algorithm that gives the GCD of two given numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

A Write the algorithm to concatenate two given strings?

a write the algorithm to concatenate two given string


Write an algorithm and draw a corresponding flowchart to search a number in the given list of numbers and also display its position?

please give me an algorithm and a corresponding flow chart that displays list of numbers from 1 to 20.


Can you write an algorithm to find the beast numbers?

maybe


Write algorithm compute sum of square of N numbers?

1. Design an algorithm to compute sum of the squares of n numbers?


Write an algorithm to check whether a number is a prime number or not?

You can write out this algorithm. This will then be programmed into the device to make determining prime numbers easier.


Write algorithm and draw flowchart to find the sum of even numbers?

jgfujtf


Write an algorithm to print sum of all even numbers?

Start print "the sum of all even numbers is infinite" end


What is algorithm to write algorithm to the program to access a pointer variable in structure?

Here is the algorithm of the algorithm to write an algorithm to access a pointer in a variable. Algorithmically.name_of_the_structure dot name_of_the _field,eg:mystruct.pointerfield


Write an algorithm to find the root of quadratic equation?

Write an algorithm to find the root of quadratic equation


How to write a java program that determines the number of prime numbers less than N which is given by the user?

where to start? do you have an algorithm and just want to implement it in java? depends on how big N is, as that will determine which method is most efficient


How to write an algorithm that accepts five numbers and displays the sum and average of the numbers?

1.Start Algorithm 2.Enter first number 3.Enter second number 4.Enter third number 5.Enter fourth number 6.Enter fifth number 7.Add five number 8.display five number / 2 9.Display result 10.End Algorithm


How do you write a fraction or decimal that has a value between the given numbers?

Without knowing what the numbers are, I would suggest taking the mean of the given numbers.