Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """Hacer un script con funciones que calcule el factorial de un nro
- Ejemplo
- 7! = 7 x 6 x 5 x 4 x 3 x 2 x 1
- 5! = 5 x 4 x 3 x 2 x 1
- """
- def factorial(n):
- fact = n
- for i in range(n-1, 0, -1):
- fact = fact * i
- return fact
- print("Cálculo del factorial de un número entero")
- numero = int(input("Ingrese un número entero: "))
- fact = factorial(numero)
- print(fact)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement