Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

fibonacci series python recursion

# By recursion
def fib(n):
    if n == 1 or n == 2:
        return 1 
    else:
        return(fib(n-1) + fib(n-2))
        
n = 6
for i in range(1,n+1):
    print(fib(i))
 
PREVIOUS NEXT
Tagged: #fibonacci #series #python #recursion
ADD COMMENT
Topic
Name
4+6 =