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
Prijavite se za ogled zgodovine oddaj
PrijavaPrijavite se za uporabo mentorja UI
PrijavaVisible tests
1
Input
10Expected
552
Input
30Expected
8320403
Input
0Expected
04
Input
1Expected
15
Input
20Expected
67656
Input
31Expected
1346269Focus radio
Paused · SomaFM · Fluid