Fibonacci Value

Fibonacci numbers follow a simple rule: each new number is the sum of the two before it. Given n, return the n-th Fibonacci number, where fib(0) = 0, fib(1) = 1, and fib(n) = fib(n-1) + fib(n-2). Try not to recompute the same values again and again.

Примеры

Ввод
[10]
Вывод
55
Ввод
[30]
Вывод
832040
Ввод
[0]
Вывод
0

Нужно реализовать

def fib(n: int) -> int:

Теги

dpmathrecursion
PostgreSQLv16

Ovdje će se prikazati rezultat izvršavanja koda

Visible tests
1
Input
10
Expected55
2
Input
30
Expected832040
3
Input
0
Expected0
4
Input
1
Expected1
5
Input
20
Expected6765
6
Input
31
Expected1346269
Focus radio
Paused · SomaFM · Fluid