Skip to content

update gcd #2639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Next Next commit
Update gcd.py
  • Loading branch information
Inbaselvan-ayyanar authored Apr 29, 2025
commit 435b29b2eb86d4be9b73fb86110d063c8598b8d5
10 changes: 5 additions & 5 deletions gcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
a = int(input("Enter number 1 (a): "))
b = int(input("Enter number 2 (b): "))

i = 1
while i <= a and i <= b:
if a % i == 0 and b % i == 0:
gcd = i
i = i + 1
def calc_GCD(x,y):
if y==0:
return x
return calc_GCD(y,x%y)
gcd=calc_GCD(a,b)

print("\nGCD of {0} and {1} = {2}".format(a, b, gcd))