Skip to content

Instantly share code, notes, and snippets.

@hector117
Created March 2, 2017 17:04
Show Gist options
  • Save hector117/aadc55d96341b3b1698431f84bd3d2e0 to your computer and use it in GitHub Desktop.
Save hector117/aadc55d96341b3b1698431f84bd3d2e0 to your computer and use it in GitHub Desktop.
def Fibonacci (x):
if x == 0:
fibo = 0
elif x == 1:
fibo = 1
else:
cont = 2
fibo = 1
ant = 0
while cont <= x:
cont = cont + 1
fibo = fibo + ant
ant = fibo - ant
pass
return fibo
def Fibonacci_2 (y):
if y == 0:
return 0
elif y == 1:
return 1
else:
fibo2= (Fibonacci_2(y-1)+Fibonacci_2(y-2))
return fibo2
#main program below
print("Quiz 08")
print("Ingresa el término de la serie de Fibonacci que quieras conocer")
x = int(input())
print("El término que ingresaste",x,"es el número",Fibonacci (x),"de la serie de Fibonacci")
print("Ingresa el término de la serie de Fibonacci que quieras conocer")
y = int(input())
print("El término que ingresaste",y,"es el número",Fibonacci_2 (y),"de la serie de Fibonacci")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment