Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  gcd
Language: C/C++
Code:
#include <stdio.h> 
int gcd(int n1, int n2); 
int main() 

int n1,n2; 
printf("Enter two positive integers\n"); 
scanf("%d",&n1); 
scanf("%d",&n2); 
printf("G.C.D of %d and %d = %d\n", n1, n2, gcd(n1,n2)); 
return 0; 

int gcd(int n1, int n2) 

if(   n1!=n2   ) 

if(    n1>n2    ) 
return gcd(n1-n2,n2); 
else 
return gcd(n1,n2-n1); 

return n1; 
Comments: