From 1b4399323b4d41f6be9bc3b3f8736232532d078f Mon Sep 17 00:00:00 2001 From: Arsh Singh <33452790+iosdev474@users.noreply.github.com> Date: Mon, 8 Oct 2018 21:17:24 +0530 Subject: [PATCH] Added GCD_Calculate.cpp --- C++/GCD_Calculate.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 C++/GCD_Calculate.cpp 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; +}