This code does not do what the author thinks it does:
def factorial(N, result=1):
if N == 1:
return 1
return factorial(N-1, N*result)