Advertisement
nq1s788

16 номер рекурсия

Oct 19th, 2024
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.14 KB | None | 0 0
  1. def f(n):
  2.     if n == 1:
  3.         return 1
  4.     if n == 2:
  5.         return 3
  6.     return f(n - 1) * n + f(n - 2) * (n - 1)
  7.  
  8.  
  9. print(f(5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement