From fcaf6cabf16e1f1b57deb4968aa82779d3e0d9b3 Mon Sep 17 00:00:00 2001 From: Ashwin Naik <35397582+aholmes2534@users.noreply.github.com> Date: Wed, 9 Oct 2019 14:53:58 +0530 Subject: [PATCH 1/2] added euclidlemmaX.py a python program to illustrate Euclid's division lemma to find the H.C.F (or G.C.D) of two positive integers. --- euclidlemmaX.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 euclidlemmaX.py diff --git a/euclidlemmaX.py b/euclidlemmaX.py new file mode 100644 index 0000000..8a0419f --- /dev/null +++ b/euclidlemmaX.py @@ -0,0 +1,19 @@ +p = 0 +g = 0 +q = 0 +r = 0 +p = int(input("Enter the larger number.")) +g = int(input("Enter the smaller number.")) + +while 1: + q = p//g + r = p % g + # print(p,",",g,",",q,",",r) + + if r == 0: + break + p = g + g = r + +print("H.C.F = ", g) +# print(p,",",g,",",q,",",r) From 5518cb396adda6344efc5d16404d9a3aa41f1757 Mon Sep 17 00:00:00 2001 From: Ashwin Naik <35397582+aholmes2534@users.noreply.github.com> Date: Wed, 9 Oct 2019 14:55:32 +0530 Subject: [PATCH 2/2] Update euclidlemmaX.py --- euclidlemmaX.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/euclidlemmaX.py b/euclidlemmaX.py index 8a0419f..041fbae 100644 --- a/euclidlemmaX.py +++ b/euclidlemmaX.py @@ -6,8 +6,8 @@ g = int(input("Enter the smaller number.")) while 1: - q = p//g - r = p % g + q = p//g #quotient (integer only, notice the // operation) + r = p % g #remainder # print(p,",",g,",",q,",",r) if r == 0: