Write a Python function to return Tribonacci's Sequence


Topic: Write a Python function to return Tribonacci's Sequence

Solution

def tribonacci_seq(n):
    if n >= 0:
        if n == 0:
            return 0
        elif n == 1:
            return 1
        elif n == 2 :
            return 1
        else:
            return tribonacci_seq(n-1) + tribonacci_seq(n-2) + tribonacci_seq(n-3)
        



List all Python Programs