Skip to content

Instantly share code, notes, and snippets.

@parzibyte

parzibyte/factorial.py Secret

Created Jan 8, 2021
Embed
What would you like to do?
"""
https://parzibyte.me/blog
"""
def factorial(numero):
if numero <= 0:
return 1
factorial = 1
while numero > 0:
factorial = factorial * numero
numero -= 1
return factorial
def factorial_recursivo(numero):
if numero <= 1:
return 1
return numero * factorial(numero-1)
valor = 5
f = factorial(valor)
print(f"El factorial de {valor} es {f}")
f = factorial(valor)
print(f"El factorial (calculado de manera recursiva) de {valor} es {f}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment