domingo, 6 de agosto de 2017

The Zen of Python - Factorial

def calculate_factorial(n):
    def nfatorial(current,currentfactorial):
        if current < 2:
            return currentfactorial
        else:
            current = current - 1
            currentfactorial = currentfactorial * (current)
            return nfatorial(current,currentfactorial)
    return nfatorial(n+1,1)

Nenhum comentário:

Postar um comentário