Source

play-problems / problema03.py

Full commit
def run(n1, n2):

    n1 = int(n1)
    n2 = int(n2)

    if n1 < 0:
        n1 = n1 - (n1 * 2)

    if n2 < 0:
        n2 = n2 - (n2 * 2)

    old_n1 = n1

    if n2 > n1:
        n1 = n2
        n2 = old_n1

    if n1 == 0 or n2 == 0:
        mmc = n1
    elif n1 == 0 and n2 > 0:
        mmc = n2
    elif n1 > 0 and n2 == 0:
        mmc = n1
    else:

        res = 0

        while True:

            n1 -= n2

            if n1 > 0:
                res = n1

            elif n1 == 0:
                mmc = n2
                break
            else:
                n1 = n2
                n2 = res

    print mmc

if __name__ == '__main__':

    run()