Advertisement
XeBuZer0

Fibonacci's secuence in python (recursive)

Dec 22nd, 2019
601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. # Este programa en python calcula el n-ésimo término de la suceśión de Fibonacci
  2. # Licenciado bajo GNU's Not Unix General Public Licence (GNU GPL) versión 3
  3. def Fibo(x):
  4.     if x<0:
  5.         print("WARNING: Su número es negativo\nse cambia a positivo...")
  6.         return Fibo((-1)*x)
  7.     elif 0<=x and x<=1:
  8.         return x
  9.     else:
  10.         return Fibo(x-1)+Fibo(x-2)
  11. print(Fibo(int(input("Ingrese un número natural:   "))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement