Answers for "Program to Print first 'n' terms of the Fibonacci series using function, 'n' is accepted from the user (using user defined module)"

2

fibonacci sequence python

# WARNING: this program assumes the
# fibonacci sequence starts at 1
def fib(num):
  """return the number at index num in the fibonacci sequence"""
  if num <= 2:
    return 1
  return fib(num - 1) + fib(num - 2)


print(fib(6))  # 8
Posted by: Guest on April-10-2020

Code answers related to "Program to Print first 'n' terms of the Fibonacci series using function, 'n' is accepted from the user (using user defined module)"

Python Answers by Framework

Browse Popular Code Answers by Language