Skip to content

Commit

Permalink
Merge pull request #6 from i-vishi/master
Browse files Browse the repository at this point in the history
Euclidian algorithm to find GCD of two numbers
  • Loading branch information
i-vishi authored Oct 1, 2018
2 parents 115edbf + 9fd5546 commit ac3eb0d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions CPP/GCD.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

// C++ program to find GCD of two numbers
#include <iostream>

// Recursive function to return gcd of a and b
int gcd(int a, int b){
if (b == 0)
return a;
return gcd(b, a % b);
}

int main(){
int a, b;
cin>>a>>b;
cout<<"GCD of "<<a<<"and "<<b<<"is : "<<gcd(a, b)<<endl;
return 0;
}

0 comments on commit ac3eb0d

Please sign in to comment.