Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 8, 2021 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/5f3c903a63537223a49f46f1a56e3efb to your computer and use it in GitHub Desktop.
Save parzibyte/5f3c903a63537223a49f46f1a56e3efb to your computer and use it in GitHub Desktop.
"""
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