Advertisement
XeBuZer0

Padovan's secuence in Python (Iterative)

Dec 22nd, 2019
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 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.     acum = a = 0
  5.     b = c = 1
  6.     for i in range(1,abs(x)):
  7.         acum = a + b
  8.         a = b
  9.         b = c
  10.         c = acum
  11.     return acum
  12. print(Pado(int(input("Ingrese un número natural:   "))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement