From 974a8cde92e26fc933c59b9246ed8aafccf841e5 Mon Sep 17 00:00:00 2001 From: SEEMA-SARDANA <65162222+SEEMA-SARDANA@users.noreply.github.com> Date: Wed, 28 Oct 2020 01:38:27 +0530 Subject: [PATCH 1/3] Create great common divisor --- Miscellaneous/great common divisor | 1 + 1 file changed, 1 insertion(+) create mode 100644 Miscellaneous/great common divisor diff --git a/Miscellaneous/great common divisor b/Miscellaneous/great common divisor new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Miscellaneous/great common divisor @@ -0,0 +1 @@ + From 7961c8f3b72691a0c0738394817eb670d8e62bc5 Mon Sep 17 00:00:00 2001 From: SEEMA-SARDANA <65162222+SEEMA-SARDANA@users.noreply.github.com> Date: Wed, 28 Oct 2020 01:41:20 +0530 Subject: [PATCH 2/3] GreatestCommonDivisor.cpp Added cpp program to find gcd of two numbers --- Miscellaneous/GreatestCommonDivisor.cpp | 28 +++++++++++++++++++++++++ Miscellaneous/great common divisor | 1 - 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Miscellaneous/GreatestCommonDivisor.cpp delete mode 100644 Miscellaneous/great common divisor diff --git a/Miscellaneous/GreatestCommonDivisor.cpp b/Miscellaneous/GreatestCommonDivisor.cpp new file mode 100644 index 0000000..cff81c0 --- /dev/null +++ b/Miscellaneous/GreatestCommonDivisor.cpp @@ -0,0 +1,28 @@ +using namespace std; +// Recursive function to return gcd of a and b +int gcd(int a, int b) +{ + // Everything divides 0 + if (a == 0) + return b; + if (b == 0) + return a; + + // base case + if (a == b) + return a; + + // a is greater + if (a > b) + return gcd(a-b, b); + return gcd(a, b-a); +} + +// Driver program to test above function +int main() +{ + int a, b; + cin>>a>>b; + cout<<"GCD of "< Date: Wed, 28 Oct 2020 01:47:32 +0530 Subject: [PATCH 3/3] Update GreatestCommonDivisor.cpp --- Miscellaneous/GreatestCommonDivisor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Miscellaneous/GreatestCommonDivisor.cpp b/Miscellaneous/GreatestCommonDivisor.cpp index cff81c0..199d518 100644 --- a/Miscellaneous/GreatestCommonDivisor.cpp +++ b/Miscellaneous/GreatestCommonDivisor.cpp @@ -1,3 +1,4 @@ +#include using namespace std; // Recursive function to return gcd of a and b int gcd(int a, int b)