$ 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
This is not a question, this is your homework. For a start, read this: https://en.wikipedia.org/wiki/Eight_queens_puzzle
maybe
1. Design an algorithm to compute sum of the squares of n numbers?
You can write out this algorithm. This will then be programmed into the device to make determining prime numbers easier.
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);
jgfujtf
By preparing test cases we can test an algorithm. The algorithm is tested with each test case.
Start print "the sum of all even numbers is infinite" end
please give me an algorithm and a corresponding flow chart that displays list of numbers from 1 to 20.
Because a tree is a recursive data-structure. It's easier to write (and easier to understand) a recursive program for handling it.
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