Python Forum

Full Version: lcm
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
def lcm(m,n):
	answer = 0
	if m>n:
		for i in range(m,m*n+1,m):
			if i%n==0:
				answer==i
				break
	return answer

>>> lcm(5,3)
0
why does it give 0?
shouldn't answer hold the value 15?
check line 6:
== is equality/comparison operator
= is assignment operator
silly me!!
thank you so much