Write a Python function to return perrin's number


Topic: Write a Python function to return perrin's number

Solution

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



List all Python Programs