This commit is contained in:
Electrominch
2022-10-12 02:30:23 +03:00
parent 02afed9c4c
commit 01c5720116
39 changed files with 517 additions and 30 deletions

View File

@@ -0,0 +1,20 @@
namespace _509._Fibonacci_Number;
public class Solution
{
public int Fib(int n)
{
if (n == 0)
return 0;
n--;
int cur0 = 0;
int cur1 = 1;
while (--n > 0)
{
int buf = cur0 + cur1;
cur0 = cur1;
cur1 = buf;
}
return cur0 + cur1;
}
}