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; +}