answersLogoWhite

0


Best Answer

$ cat gcd.c

#include

int gcd_recursive(int a, int b)

{

if (b == 0)

return a;

return gcd_recursive(b, a % b);

}

int main()

{

printf("GCD of 10 and 25: %d\n", gcd_recursive(10, 25));

return 0;

}

$ gcc gcd.c -o gcd

$ ./gcd

GCD of 10 and 25: 5

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a recursive algorithm to find the GCD of two numbers 5 Marks?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write and explain recursive backtracking algorithm for n-queens?

This is not a question, this is your homework. For a start, read this: https://en.wikipedia.org/wiki/Eight_queens_puzzle


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.


What is recursive algorithm and write a recursive algorithm to reverse a string also trace it for any string data?

A recursive algorithm is an algorithm which calls itself with "smaller (or simpler)" input values, and which obtains the result for the current input by applying simple operations to the returned value for the smaller (or simpler) input. Heres a recursive algorithm to reverse a string char *rev(char str[],int pos1,int pos2) { if(pos1<pos2) { char temp=str[pos1]; str[pos1]=str[pos2]; str[pos2]=temp; return rev(str,pos1+1,pos2-1); } return str; } You can call this function like this char *r=rev("reverse it",0,9);


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

jgfujtf


Where do you run an algorithm?

By preparing test cases we can test an algorithm. The algorithm is tested with each test case.


Write an algorithm to print sum of all even numbers?

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


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.


Why recursive solution is better for tree traversal?

Because a tree is a recursive data-structure. It's easier to write (and easier to understand) a recursive program for handling it.


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