i was trying to solve problem 5 using a gcd and lcm function and a for loop to iterate the lcm (yes, i'm a beginner). However, the loop does not seem to work and the output is always equal to 1. What do I do wrong? I'm using the python 3.4.1 shell

- Code: Select all
`from fractions import gcd`

def lcm(a,b):

return int((a*b)/gcd(a,b))

def problem(n):

answer=1

for i in range(1,n):

answer = lcm(i, answer)

return answer

print(problem(10))