FIB_R(n)
- if n = 1 or n = 2 then
- return 1
- else
- return FIB_R(n-1) + FIB_R(n-2)
FIB_NR(n)
- A[1] ← 1
- A[2] ← 1
- for i ← 3 to n do
- A[i] ← A[i-1] + A[i-2]
- return A[n]
COIN_ROW(C[1..n])
- F[0] ← 0
- F[1] ← C[1]
- for i ← 2 to n do
- F[i] ← max(F[i-2]+C[i],F[i-1])
- return F[n]