On Wed, 14 Nov 2012 19:52:03 +0200, Selby Rowley Cannon
<selbyrowleycan...@ymail.com> wrote:
Hey,
I've been trying to write a function to find the Lowest Common
Multiple of two numbers, but it isn't working and I've kinda hit a dead
end on the thought-process end of things. Anyone mind looking at it, and
tell me what's wrong? (I hop you don't think it's too long to put in an
email)
Code:
def lowestCommonMultiple(a, b, amount): #k
float(amount)
if a == b:
print 'You cannot find the LCM of the same number twice.'
else:
numbersList = list(range(amount))
aMultiples = []
bMultiples = []
for aNumber in numbersList:
aMultiples.append(a*aNumber)
for bNumber in numbersList:
bMultiples.append(b*bNumber)
if aMultiples[1] == bMultiples[1]:
print 'The LCM of ', a, ' and ', b, ' is ', aMultiple[1]
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Hello World,
I have script I wonder if it would be suitable:
def LCM(x,y):
for n in range(1, 10000):
for n2 in range(1, 10000):
x_lcm = x*n
y_lcm = y*n2
if x_lcm == y_lcm:
print"The LCM of",x,"and",y,"is",x_lcm
return x_lcm
else:
pass
dx
--
守破離(shuhari) first learn, then detach, and finally transcend
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor