Recursive Fibonacci

    0

    0

    Mahendra Kumar

    beginnerfucntionCallingItself

    performing Fibonacci series in python using recursion. recursion means a defined function can call itself.

    def fibonacci(n):
        if(n <= 1):
            return n
        else:
            return(fibonacci(n-1) + fibonacci(n-2))
    n = int(input("Enter number of terms:"))
    print("Fibonacci sequence:")
    for i in range(n):
        print(fibonacci(i))
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.