Guest User

Untitled

a guest
Aug 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #fibonacii series of a no using recursion
  2. def fib(n):
  3. if n<=1:
  4. return n
  5. else:
  6. return (fib(n-1) + fib(n-2))
  7.  
  8. n = int(input("Enter number of terms:"))
  9. print("Fibonacii series are: ")
  10. for i in range (n):
  11. print(fib(i))
  12.  
  13. #for factorial
  14. n=int(input("Enter the no to find factorial: "))
  15. def facts(n):
  16. if n == 0 or n == 1:
  17. return 1
  18. if n>=1:
  19. return n * facts(n-1)
  20. print("The facatorial of a given no",str(n),"is:",facts(n))
Add Comment
Please, Sign In to add comment