diff --git a/C++/GCD_Calculate.cpp b/C++/GCD_Calculate.cpp new file mode 100644 index 000000000..86e02a578 --- /dev/null +++ b/C++/GCD_Calculate.cpp @@ -0,0 +1,21 @@ +#include +using namespace std; + +int main() +{ + int n1, n2; + + cout << "Enter two numbers: "; + cin >> n1 >> n2; + + while(n1 != n2) + { + if(n1 > n2) + n1 -= n2; + else + n2 -= n1; + } + + cout << "HCF = " << n1; + return 0; +}