Skip to content

Commit 47c5d46

Browse files
authored
Merge pull request thuva4#258 from saad1504/algo-branch
Recursive Eucledian Algorithm implementation in C++
2 parents 6496eed + 9440ea1 commit 47c5d46

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include<iostream>
2+
using namespace std;
3+
//Recursive Function to calculate GCD
4+
int gcd(int a,int b)
5+
{
6+
if(b==0)
7+
return a;
8+
else
9+
return gcd(b,(a%b));
10+
}
11+
//Driver program
12+
int main()
13+
{
14+
int a,b;
15+
cout << "Enter the two numbers to calculate gcd" << endl;
16+
cin >> a >>b;
17+
cout <<"Gcd of " << a << " " << b << "is "<< gcd(a,b)<< endl;
18+
return 0;
19+
}

GreatestCommonDivisor/C++/a.out

9.13 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Fast Fourier Transform | | | | | :+1: | | | |
2525
Fibonacci | :+1: | :+1: | | :+1: | | | :+1: | | :+1:
2626
FisherYatesShuffle | :+1: | | | | :+1: | :+1: | | :+1: |
2727
Floyd'sAlgorithm | :+1: | :+1: | | | :+1: | | | |
28-
GreatestCommonDivisor | :+1: | | :+1: | :+1: | | | | |
28+
GreatestCommonDivisor | :+1: | | :+1: | :+1: | :+1: | | | |
2929
HammingDistance | :+1: | :+1: | | | | :+1: | | |
3030
HeapSort | :+1: | :+1: | | | :+1: | :+1: | :+1: | | :+1:
3131
HistogramEqualization | :+1: | | | | | | | |

0 commit comments

Comments
 (0)