Skip to content
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

这里没写好 #2469

Open
zion-chuu opened this issue Mar 7, 2024 · 1 comment
Open

这里没写好 #2469

zion-chuu opened this issue Mar 7, 2024 · 1 comment

Comments

@zion-chuu
Copy link

int fibonacci(int i) {
       if(i <= 0) return 0;
       if(i == 1) return 1;
       return fibonacci(i-1) + fibonacci(i-2);
}

直接写成:

int fibonacci(int i) {
       if(i <= 1) return i;
       return fibonacci(i-1) + fibonacci(i-2);
}

不就好了

@LYT0905
Copy link
Contributor

LYT0905 commented Mar 10, 2024

单从代码来看,如果i是小于0的数你怎么办

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants