New user needs help

John pantsmetalkid at charter.net
Sat Feb 21 00:16:37 EST 2004


I am new to using Python. Everytime I run this program it prints "The lowest
common factor is 0", no matter what numbers I use. Can anybody see anything
wrong with my program? Thanks in advance.



def getnum1(a):
    a = input("What is the first number?")
    if a == 0:
        getnum1(a)
def getnum2(b):
    b = input("What is the second number?")
    if b == 0:
        getnum2(b)
def euclid(num1, num2, num3, num4):
    if num1 < num2:
        num3, num4 = num1, num2
        num1, num2 = num4, num3
        euclid(num1, num2, num3, num4)
    elif num2 != 0:
        num3, num4 = num1, num2
        num1 = num4
        num2 = num3 % num4
        euclid(num1, num2, num3, num4)
    else:
        print "The lowest common factor is: ", num1
a = 0
getnum1(a)
b = 0
getnum2(b)
x, y = 2, 100
euclid(a, b, x, y)





More information about the Python-list mailing list