I have a code that basically solves one of the problem in Project Euler and aims to find out LCM of first 20 natural numbers.
def GCD(a, b): #Euclid's algorithim
if (b == 0):
return a
else:
GCD(b, a % b)
def LCM(a, b): #LCM(a,b) = a*b/GCD(a,b)
x = GCD(a, b)
return ((a * b)/x)
def RFIND(a, b):
if (b == 20):
return a
else:
RFIND(LCM(a, b), b + 1)
print RFIND(2, 1)
But I face an error while running it.
return ((a * b)/x)
TypeError: unsupported operand type(s) for /: 'int' and 'NoneType'
May I know Why?
Try
You have to return the value returned by the recursive call.
RFINDhas a similar problem.