####################################################[br]#11 Ejemplos de Secuencias Recursivas en Python:[br][br]#1. Secuencia de Fibonacci:[br]def fibonacci(n):[br] if n <= 1:[br] return n[br] else:[br] return fibonacci(n-1) + fibonacci(n-2)[br][br]#2. Secuencia de Lucas:[br]def lucas(n):[br] if n == 0:[br] return 2[br] elif n == 1:[br] return 1[br] else:[br] return lucas(n-1) + lucas(n-2)[br][br]#3. Secuencia de Pell:[br]def pell(n):[br] if n == 0:[br] return 0[br] elif n == 1:[br] return 1[br] else:[br] return 2*pell(n-1) + pell(n-2)[br][br]#4. Secuencia de Padovan:[br]def padovan(n):[br] if n == 0 or n == 1 or n == 2:[br] return 1[br] else:[br] return padovan(n-2) + padovan(n-3)[br][br]#5. Secuencia de Hofstadter Q:[br]def hofstadter_q(n):[br] if n == 0 or n == 1:[br] return 1[br] else:[br] return hofstadter_q(n - hofstadter_q(n-1)) + hofstadter_q(n - hofstadter_q(n-2))[br][br]#6. Secuencia de Hofstadter G:[br]def hofstadter_g(n):[br] if n == 0:[br] return 0[br] elif n == 1:[br] return 1[br] else:[br] return n - hofstadter_g(hofstadter_g(n-1))[br][br]#7. Secuencia de Jacobsthal:[br]def jacobsthal(n):[br] if n == 0:[br] return 0[br] elif n == 1:[br] return 1[br] else:[br] return jacobsthal(n-1) + 2*jacobsthal(n-2)[br][br]#8. Secuencia de Narayana:[br]def narayana(n):[br] if n == 0 or n == 1:[br] return 1[br] else:[br] return narayana(n-1) + narayana(n-2)[br][br]#9. Secuencia de Perrin:[br]def perrin(n):[br] if n == 0:[br] return 3[br] elif n == 1:[br] return 0[br] elif n == 2:[br] return 2[br] else:[br] return perrin(n-2) + perrin(n-3)[br][br]#10. Secuencia de Triangular:[br]def triangular(n):[br] if n == 0:[br] return 0[br] else:[br] return n + triangular(n-1)[br][br]#11. Secuencia de Pentanacci:[br]def pentanacci(n):[br] if n == 0 or n == 1 or n == 2:[br] return 0[br] elif n == 3 or n == 4:[br] return 1[br] else:[br] pentanacci_seq = [0, 0, 0, 1, 1][br] for i in range(5, n+1):[br] pentanacci_seq.append(pentanacci_seq[i-1] + pentanacci_seq[i-2] + pentanacci_seq[i-3] + pentanacci_seq[i-4] + pentanacci_seq[i-5])[br] return pentanacci_seq[n][br]# Ejemplo de uso[br]print(pentanacci(7)) # Salida: 2[br]