>>> def lcm(a,b):
if a<<b:
c=a
a=b
b=c
c=0
lit=[a,b,c]
n=3
while (not lit[n%3]%lit[(n%3)+1]==0):
lit[(n%3)+2]=lit[n%3]%lit[(n%3)+1]
if lit[(n%3)+2]==0:
d=lit[(n%3)+2]
print d
else:
n=n+1
This is the code, trying to build a function lcm that finds the least common multiplier of a and b. Not really the cleanest code of the bunch, but sadly this was all I could do. It would really be nice if this lump of code could be a little lighter.
So, err, back to the point, I called for lcm, and it just blurts out error messages.
This is what it says:
>>> lcm(78696,19332)
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
lcm(78696,19332)
File "<pyshell#1>", line 10, in lcm
lit[(n%3)+2]=lit[n%3]%lit[(n%3)+1]
IndexError: list assignment index out of range
Aaaaand I have got absolutely no idea what I am supposed to do now.
What can I do now?