Write a Python function to return Pell's Sequence


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

Solution

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



List all Python Programs