On 14/11/12 18:27, Dave Angel wrote:
On 11/14/2012 12:52 PM, Selby Rowley Cannon 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]
Which are you interested in, finding what's wrong with the code, or a
simpler way to actually find an LCM ?
Is this an assignment, or just part of a bigger program you're writing?
a.) Finding what's wrong with the code;
b.) Part of a bigger program.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor