Got a solution but still get an indexError
<p>I have written this python code. When I run it I get an index error at the end;
I don't know why. I was wondering if someone could help me out.</p>

<p>The problem is to find the smallest positive number that is evenly divisible by all of the
numbers from 1 to 20. My analysis is correct but just the code at the end is giving me hard time.</p>

<pre><code>def leastCommonDenominator(num1, num2):
    '''
        Returns the least common denominator of two numbers
    '''
    num2List = range(1,num2+1)
    if num1 &lt; num2:
        for i in num2List:
            if (num1*num2List[i]) % num2 == 0:
                return num1*num2List[i]
    num1List = range(1, num1+1)
    if num2 &lt; num1:
        for i in num1List:
            if (num2*num1List[i]) % num1 == 0:
                return num2*num1List[i]
    else:
        return num1

def leastNum():
    '''
        Prints the least number divisible
    '''
    myList = range(1,4)
    print myList
    num = 1
    for i in myList:
        num = leastCommonDenominator(num, myList[i])
        print num    

def main():
    leastNum()
</code></pre>
