From c42ad20b67bd1f8d4f56fde72853301ea37695dd Mon Sep 17 00:00:00 2001 From: abdurrezzak Date: Sun, 22 Oct 2017 12:20:48 +0300 Subject: [PATCH] Add files via upload --- 4.EuclidianGCD.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 4.EuclidianGCD.cpp diff --git a/4.EuclidianGCD.cpp b/4.EuclidianGCD.cpp new file mode 100644 index 0000000..7a934c7 --- /dev/null +++ b/4.EuclidianGCD.cpp @@ -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 +#include +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 " <