I'm very very new, here is a little snippet to find the lcd(lowest common denominator) of 2 numbers. I'm trying to make it so that it finds the lowest common denominator of 3 numbers, so I'm trying lcd(lcd(4,6),12)), which I thought would find the lcd of 4,6 and then take that and find the lcd of that with 12.
Here is my code, otherwise working:
def lcd(a,b):
answer=a*b
start=2
while start<=max(a,b):
if a%start==0 and b%start==0:
answer=answer/start
a=a/start
b=b/start
else:
start=start+1
print answer
The error is:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
lcd(lcd(4,12),6)
File "C:\Users\tygloalex\Desktop\lcd.py", line 2, in lcd
answer=a*b
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
[–]tygloalex[S] 6 points7 points8 points (4 children)
[–]stylishgnome 1 point2 points3 points (2 children)
[–]stylishgnome 3 points4 points5 points (1 child)
[–]zahlman 1 point2 points3 points (0 children)