Advertisement
ihor_ks

nfactorial.py

Nov 6th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. #The program for calculating n! recursively
  4.  
  5. def fac(n):
  6.     """n! recursive"""
  7.     if n == 0:
  8.         return 1
  9.     return fac(n-1) * n
  10.  
  11. n = int(input('Enter positive integer:\n>'))
  12. print("Factorial",(n),":",fac(n))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement