---
# System prepended metadata

title: WDI 5.4

---

---
title: WDI 5.4
---
```python=
from lib.wdi import *

MaxN = 1000

def zad_4(n):
    tab = Array(MaxN)
    for i in range (0, 3):
        tab[i] = 1
    for i in range (3, n+1):
        tab[i] = tab[0] + tab[1] + tab[2]
        for j in range (0, 2):
            tab[j] = tab[j+1]
        tab[2] = tab[i]
    print (tab[2])

zad_4(50)


#v.2
from lib.wdi import Array

MaxN = 1000

def zad_4(n):
    tab = Array(MaxN)
    for i in range (0, 3):
        tab[i] = 1
    for i in range (3, n+1):
        tab[3] = tab[0] + tab[1] + tab[2]
        for j in range (0, 3):
            tab[j] = tab[j+1]
    print (tab[2])

zad_4(50)

"""
pamięć - 4
czas - 4*(n-3) + 3 
"""





"""
pamięć - 4
czas - 4*(n-3) + 3 
"""
```