Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
lcm
#1
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?
Reply
#2
check line 6:
== is equality/comparison operator
= is assignment operator
Reply
#3
silly me!!
thank you so much
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020