Advertisement
XeBuZer0

Padovan's secuence in Python (recursive)

Dec 22nd, 2019
748
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 Padovan
  2. # Licenciado bajo GNU's Not Unix General Public Licence (GNU GPL) versión 3
  3. def Pado(x):
  4.     if x<0:
  5.         print("WARNING: Su número es negativo\nse cambia a positivo...")
  6.         return Pado((-1)*x)
  7.     elif 0<=x and x<=2:
  8.         return 1
  9.     else:
  10.         return Pado(x-3)+Pado(x-2)
  11. print(Pado(int(input("Ingrese un número natural:   "))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement