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,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>_509._Fibonacci_Number</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,8 @@
namespace _509._Fibonacci_Number;
internal class Program
{
static void Main(string[] args)
{
}
}

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;
}
}