From 670761e26b86cf69002c68e316a164833a65a1b9 Mon Sep 17 00:00:00 2001 From: arpitsinghania8 <46151083+arpitsinghania8@users.noreply.github.com> Date: Fri, 25 Oct 2019 18:20:06 +0000 Subject: [PATCH] Create gcd.cpp --- Elemental algorithms/gcd.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Elemental algorithms/gcd.cpp diff --git a/Elemental algorithms/gcd.cpp b/Elemental algorithms/gcd.cpp new file mode 100644 index 0000000..a054635 --- /dev/null +++ b/Elemental algorithms/gcd.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; + +int gcd(int a, int b){ + if (b==0) + { + return a; + } + else{ + int c = a%b; + return gcd(b,c); + } +} + +int main() +{ + int a=12,b=6; + std::cout << gcd(a,b) << endl; + return 0; +}