fibonacci series using function

As we all know,python is an easy  to start programming language.

coding program are the most problems given in hiring interviews.

So,lets get started with basic programs.
problem:find the nth element in fibonacci series.

sample input:7

sample output:13

python code:

def fib(n):
    if(n==0):
        return 0
    elif(n==1):
        return 1
    else:
        return fib(n-1)+fib(n-2)

n=int(input('enter an integer value'))
for i in range(0,n+1):
    x=fib(i)

print(x) 

Comments

Popular posts from this blog

MESSAGE sending problem FIXED for all networks and mobiles

star patterns in python

python code for FLAMES