-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7e4e75
commit c42ad20
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* This program takes two numbers as input and | ||
* calculates their greates common divisor using | ||
* Euclidian Algorithm | ||
* For more information about the Algorithm: https://en.wikipedia.org/index.php?q=aHR0cHM6Ly9lbi53aWtpcGVkaWEub3JnL3dpa2kvRXVjbGlkZWFuX2FsZ29yaXRobQ | ||
* | ||
* Coded by: Abdurrezak EFE | ||
* | ||
* */ | ||
#include <iostream> | ||
#include <algorithm> | ||
using namespace std; | ||
|
||
int gcd(int a, int b) | ||
{ | ||
if(a%b == 0) | ||
return b; | ||
else | ||
return gcd(b,a%b); | ||
} | ||
|
||
int main() | ||
{ | ||
int a,b; //taking the inputs | ||
cin >> a >> b; | ||
|
||
cout << "GCD of " << a << " and " <<b <<" is: " << gcd(a,b) << endl; | ||
|
||
} |