opt_folge.py 277 B

12345678910111213141516
  1. #!/usr/bin/env python3
  2. def opt_folge(n):
  3. f = list()
  4. for i in range(n + 1):
  5. f.append(0)
  6. if i <= 2:
  7. continue
  8. if i == 3:
  9. f[i] = 1
  10. continue
  11. f[i] = f[i - 1] + 2 * f[i - 2] + 3 * f[i - 3]
  12. return f[n]
  13. print([opt_folge(n) for n in range(30)])