509. Fibonacci Number
All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : June 17, 2024
Last updated : June 17, 2024
Related Topics : Math, Dynamic Programming, Recursion, Memoization
Acceptance Rate : 72.32 %
int fib(int n){
int a = 0;
int b = 1;
while (n > 0) {
int temp = a + b;
a = b;
b = temp;
n--;
}
return a;
}