# ==============================================================================
"""FIBO : compute the n first terms of the Fibonacci sequence"""
# ==============================================================================
__author__  = "Philippe Blasi"
__version__ = "2.0" # use recursive implementation of the Fibonacci terms
__date__    = "2026-02-13"
__usage__   = """
User input: <n> (where n:int >= 0)
App output: sequence of the n first Fibonacci terms"""
# ==============================================================================
from ezCLI import *
# ------------------------------------------------------------------------------
def fibo(n:int) -> int:
  """return the nth term of the Fibonacci sequence (recursive version)"""
  if n == 0:
      return 0
  elif n == 1:
      return 1
  else:
      return fibo(n-1)+fibo(n-2)
# ------------------------------------------------------------------------------
def fibos(n:int) -> str:
  """return a string containing the 'n' first terms of the Fibonacci sequence"""
  lines = [f"fibo{p} = {fibo(p)}" for p in range(0,n+1)]; #inspect()
  return '\n'.join(lines)
# ------------------------------------------------------------------------------
def parser(command:str) -> str:
  """parse 'command' as integer 'n' before calling 'fibos(n)'"""
  n = parse(command); #inspect()
  assert type(n) is int and n >= 0, "<n> must be a positive integer"
  return fibos(n)
# ==============================================================================
if __name__ == "__main__":
  userloop(parser, "Enter value for <n>")
# ==============================================================================
