Skip to content
Open
Changes from all commits
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
27 changes: 14 additions & 13 deletions [1]. Math Implementation/1.1 Fibonacci Implementation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,21 @@ long long Fibonacci(unsigned n)
### Java

```java
public static int Fibonacci( int n ){

if( n==0 || n==1 ){
return 1;
}
else if(n>1){

return Fibonacci(n-1)+Fibonacci(n-2);
}
else{

return 0;
public static int Fibonacci( int n ) {
if (n < 2) {
return 1;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里缩进要修改一下~

}

int first = 0;
int second = 1;
int current = 0;
for (int i = 2; i <= n; i++) {
current = first + second;
first = second;
second = current;
}
return current;
}
}
```