Facebook
From light yagami, 1 Year ago, written in Python.
Embed
Download Paste or View Raw
Hits: 302
  1. Write a recursive function to print the factorial for a given number.
  2. def recur_factorial(n):
  3. if n==1:
  4. return
  5. n
  6. else:
  7. return n*recur_factorial(n-1)
  8. num=int(input("Enter Number"))
  9. if num<0:
  10. print("Enter valid number")
  11. elif num==0:
  12. print("factorial of 0 is 1")
  13. else:
  14. print("The factorial of",num,"is",recur_factorial(num))
  15. Enter Number 5
  16. The factorial of 5 is 120

Replies to out of ur legue rss

Title Name Language When
Re: out of ur legue light python 1 Year ago.