write a c program to find GCD of two numbers using recursion

itstudentjunction

Write a C Program to find GCD of two numbers using recursion



GCD of two numbers:


The greatest common divisor (gcd), also known as the greatest common factor (gcf), or highest common factor (hcf), of two or more non-zero integers, is the largest positive integer that divides the numbers without a remainder. For example, the GCD of 8 and 12 is 4.
other examples: GCD of 12 & 18 is 6 , GCD of 9 and 12 is 3, GCD of 10 and 15 is 5

Recurrsion:

A recursive function is a function which calls itself. For this to work, the following conditions apply :
•There must be a solveable problem.
•There must be a terminating clause.




write a c program to find GCD of two numbers using recursion or check gcd of two numbers using recursion or print gcd of two numbers using recursion or calculate gcd of two numbers using recursion or show gcd of two numbers using recursion

write a c program to find GCD of two numbers using recursion or check gcd of two numbers using recursion or print gcd of two numbers using recursion or calculate gcd of two numbers using recursion or show gcd of two numbers using recursion

#include<stdio.h>
#include<conio.h>
int GCD (int a,int b)
{
if (a<0) a= -a;
if (b<0) b= -b;
if (a==0 || b==1 || a==b) return b;
if (a==1 || b==0) return a;
if (a>b) return GCD (b, a%b);
else return GCD (a, b%a);
}
void main()
{
int x,y;
clrscr();
printf("To calculate gcd of two numbers using recursion:");
printf("nEnter 1st number:");
scanf("%d",&x);
printf("nEnter 2nd number:");
scanf("%d",&y);
printf("\nGCD is:%d", GCD(x,y));
getch();
}

OUTPUT:

To calculate gcd of two numbers using recursion:

Enter 1st number: 8

Enter 2nd number:12

GCD is: 4


write a c program to find gcd of two numbers without recursion


other recursion programs


write a c program to find gcd using recursion

write a c program to find fibonacci numbers using recursion


write a c program to find factorial using recursion


write a c program to find sum of factorial series using recursion

write a c program to find reverse of a number using recursion



write a c program to find check calculate print show SI write a c program to find check calculate print show CI write a c program to find check calculate print show factorial number write a c program to find check print show even / odd write a c program to find check print show perfect number or not write a c program to find check print show prime number or not write a c program to find check calculate print show factors of numberwrite a c program to find check print show prime factors write a c program to find check calculate print show armstrong number or notwrite a c program to find check calculate print show amicable pair write a c program to find check calculate print show sum of n numbers write a c program to find check calculate print show average of n numbers write a c program to find check calculate print show largest of two numbers write a c program to find check calculate print show largest of n numbers write a c program to find check calculate print show LCM of two numberswrite a c program to find GCD of two numbers using recursion or check gcd of two numbers using recursion or print gcd of two numbers using recursion or calculate gcd of two numbers using recursion or show gcd of two numbers using recursion write a c program to find check calculate print show sum of n numbers write a c program to find check calculate print show numbers in word write a c program to find check calculate print show pascal Triangle find roots write a c program to find check calculate print show addition subtraction of complex numbers write a c program to find check calculate print show multiplication of complex numbers write a c program to find check calculate print show numbers pyramid write a c program to find check calculate print show decimal to binary write a c program to find check calculate print show decimal to octal write a c program to find check calculate print show decimal to hexadecimal write a c program to find check calculate print show sum of digits towers of hannoi write a c program to find check calculate print show palindrome number write a c program to find check calculate print show strong number or not write a c program to find check calculate print show biggest of three largest & smallest values in arraywrite a c program to find check calculate print show no, of combinationswrite a c program to find check calculate print show no.of digits write a c program to find check calculate print show no, of permutations prime numbers write a c program to find check calculate print show power value write a c program to find check calculate print show reverse number smallest number in array write a c program to find check calculate print show sum of Digits Floyd’s Triangle even or odd swap numbers implementing function implementing function Function with no arguments and a return value function with no arguments and no return value addition of two matrices multiplication of two matrices transpose of matrix inverse of matrix lower triangle upper triangle sparse matrix addition two sparse matrix multiply sparse matrix SI using macros max min values gcd using recurrsion fibonacci numbers using recursion factorial using recurrsion sum of factorial series using recursion reverse numberreverse string using recursion sizes data types automatic variable scope external variable scope static variable scope register variable scope employee data reverse string strrev reverse string pointers reverse string arrays string length strlen string length arrays string length pointers concatinate strings strCat concatinate strings arrays convert to lowercase convert to uppercase convert to lowercase check substring first occurance of character count words count vowels compare two strings arrays compare strings pointers compare strings strcmp palindrome string substring position string combinations acromatic string rain drop character copy file student records in file line styles fill styles font styles escape operators B-TREE MULTIWAY TREE AVL TREE SPLAY TREE RED BLACK TREE HASHING PRIORITY QUEUE DIJKSTRA'S ALGORITHM KNAPSACK PROBLEM ADJACENCY LIST DEPTH FIRST SEARCH MINIMAL SPANNINGTREE KRUSKAL'S ALGORITHM MINIMAL SPANNING TREE PRIMS ALGORITHM BREADTH FIRST SEARCH LINEAR SEARCH POINTERS BINARY SEARCH POINTERS LINEAR SEARCH ARRAYS BINARY SEARCH ARRAYS BUBBLE SORTARRAYS MERGE SORT ARRAYS SELECTION SORT ARRAYS INSERTION SORT ARRAYS TOPOLOGICAL SORT ARRAYS HEAP SORT ARRAYS HEAP SORT POINTERS BUBBLE SORT arrays MATRIX MULTIPLICATION TRANSPOSE OF MATRIX LEXICOGRAPHIC ORDER SUBSTRING its POSITION CONCATENATE STRINGS STUDENT INFORMATION MULTIPLY SPARCE MATRICES COUNT STRINGS LINKED LIST POINTERS REVERSE STRING PREFIX TO POSTFIX SINGLE LINKED LIST COUNT NODES LINEAR LINKED LIST CIRCULAR LINKED LIST CONCATENATE LISTS PRINT LIST ELEMENTS COMMON IN TWO LISTS SORT LIST CIRCULAR LINKED LIST REVERSE LINKED LIST SHOW POLYNOMIAL ADD POLYNOMIALS STACK ARRAYS STACk (pointers) MULTIPLE STACK EXPRESSION TREE TRAVERSALS INFIX TO POSTFIX QUEUE ARRAYS QUEUE POINTERS CIRCULAR QUEUE ARRAYS QUEUE USING ARRAYS REVERSE A QUEUE BINARY TREE BINARY TREE TRAVERSALS LEAVES OF BINARY TREE first occurrence of substring last occurrence of substring check substring C Programs Data structures Programs in c Data structures Programs in c++ Computer Graphics Programs Unix commands Linux commands HTML programmingC++ programs,Data structures Algorithms, Java Programs UML Diagrams Assembly Language Programs DBMS j2ee programming c tutorials c++ tutorials java tutorials Data structures tutorials DBMS tutorials