Akirky
Expert Member
- Joined
- Jul 16, 2011
- Messages
- 2,804
I'm slowly learning Python for a RPi project, and I'm stuck.
Can someone please point me in the right direction to extend this to get the LCM of 3 numbers? Google is giving me a headache.
def GCD(a,b): #greatest common divisor
while b:
a, b = b, a%b;
return a;
def LCM(a,b): #least common multiplier
return a*b/GCD(a,b);
Thanks.
Can someone please point me in the right direction to extend this to get the LCM of 3 numbers? Google is giving me a headache.
def GCD(a,b): #greatest common divisor
while b:
a, b = b, a%b;
return a;
def LCM(a,b): #least common multiplier
return a*b/GCD(a,b);
Thanks.