# Recursive Solution

`def nth_fibonacci(n):  if (n <= 1):    return 1  else:    return nth_fibonacci(n - 1) + nth_fibonacci(n - 2)`

# Memoization/Dynamic Programming Solution

`def fib(self, n: int) -> int:	#Initialize first two terms    dp = [0,1]    if n < 2:        return dp[n]    for i in range(1,n):        dp.append(dp[i]+dp[i-1])    return dp[-1] `

# Space Efficient Fibonacci DP Solution

`def fib(self, n: int) -> int:    #initialize length 3 array    dp = [0,1,0]    if n == 0:         return dp    elif n == 1:        return dp    else:        for i in range(1,n):            dp = dp+dp            dp = dp            dp = dp    return dp`

# Constant Time Fibonacci Solution

`def fib(self, n: int) -> int:    p = (1 + math.sqrt(5)) / 2    return round(p**n/math.sqrt(5))`

# First N Terms Sum

`def fib_sum(n):    return fib(n+2) - 1`

# First N Terms Sum Odd Indices

`def fib_odd_sum(n):    return fib(2*n)`

# First N Terms Sum Even Indices

`def fib_even_sum(n):	return fib(2*(n+1))-1`

--

--