# euclid_gcd.py
# Euclid's algorith states that starting with values m and n, if we were
# to repeatedly apply the formula: n, m = m, n%M until m is 0.
# This program finds the GCD of two numbers using this formula.
# by: Scott Gordon
defgcd(n,m):whilem!=0:n,m=m,n%mreturnndefmain():print("Welcome to Euclid's GCD algorithm\n")num1,num2=input("Enter two natural numbers (n1, n2): ").split(",")print(f"The GCD of {num1} and {num2} is {gcd(int(num1),int(num2))}")if__name__=='__main__':main()
Top comments (0)
Subscribe
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)