Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[pull] master from youngyangyang04:master #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
pull merged 5 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
Sep 28, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
添加0509斐波那契数C#版本
  • Loading branch information
xiaoyu2018 committed Sep 25, 2022
commit f48f7b0aa7b9cf5e81ee3405249e0c91296418ce
40 changes: 40 additions & 0 deletions problems/0509.斐波那契数.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -370,5 +370,45 @@ object Solution {
}
```

### C#

动态规划:

```c#
public class Solution
{
public int Fib(int n)
{
if(n<2) return n;
int[] dp = new int[2] { 0, 1 };
for (int i = 2; i <= n; i++)
{
int temp = dp[0] + dp[1];
dp[0] = dp[1];
dp[1] = temp;
}
return dp[1];
}
}
```

递归:

```c#
public class Solution
{
public int Fib(int n)
{
if(n<2)
return n;
return Fib(n-1)+Fib(n-2);
}
}
```





-----------------------
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>

AltStyle によって変換されたページ (->オリジナル) /