Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #fibonacii series of a no using recursion
- def fib(n):
- if n<=1:
- return n
- else:
- return (fib(n-1) + fib(n-2))
- n = int(input("Enter number of terms:"))
- print("Fibonacii series are: ")
- for i in range (n):
- print(fib(i))
- #for factorial
- n=int(input("Enter the no to find factorial: "))
- def facts(n):
- if n == 0 or n == 1:
- return 1
- if n>=1:
- return n * facts(n-1)
- print("The facatorial of a given no",str(n),"is:",facts(n))
Add Comment
Please, Sign In to add comment