'''
-----------------------------
 EJERCICIO N°4
 Serie de Fibonacci
-----------------------------
'''
def fib(n):
  if n < 1:
    return None
  if n < 3:
    return 1

  elem1 = elem2 = 1
  sum = 0
  for i in range(3, n + 1):
    sum = elem1 + elem2
    elem1, elem2 = elem2, sum
  return sum

# Probando la función
for n in range(1, 10): 
  print("fib",n, "->", fib(n))

'''
-----------------------------
 Utilizando recursividad
-----------------------------

def fib(n):
  if n < 1:
    return None
  if n < 3:
    return 1
  return fib(n - 1) + fib(n - 2)

# Probando la función
for n in range(1, 10): 
  print("fib",n, "->", fib(n))
'''
