-
Notifications
You must be signed in to change notification settings - Fork 24
Fibon code #59
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
base: master
Are you sure you want to change the base?
Fibon code #59
Conversation
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/* | ||
* public double fibo(int n) | ||
{ | ||
if(n<=2) | ||
f=1; | ||
else | ||
f=fibo(n-1)+fibo(n-2); | ||
return f; | ||
|
||
} | ||
|
||
public double fibo1(int n) | ||
{ | ||
if(mem[n]!=0) | ||
f=mem[n]; | ||
else if(n<=2) | ||
f=1; | ||
else | ||
f=fibo1(n-1)+fibo1(n-2); | ||
mem[n]=f; | ||
return f; | ||
|
||
} | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* | |
* public double fibo(int n) | |
{ | |
if(n<=2) | |
f=1; | |
else | |
f=fibo(n-1)+fibo(n-2); | |
return f; | |
} | |
public double fibo1(int n) | |
{ | |
if(mem[n]!=0) | |
f=mem[n]; | |
else if(n<=2) | |
f=1; | |
else | |
f=fibo1(n-1)+fibo1(n-2); | |
mem[n]=f; | |
return f; | |
} | |
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could remove the commented-out sections to make your code clean :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly in the other branch too..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, I've added the Hacktoberfest-accepted labels to your PRs, so the Hacktoberfest website count them as valid PRs.
Also, since fibonacci numbers are whole numbers, do you need to use the double datatype?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is taken as double to have larger range than int.We can use long as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, long would be the more appropriate choice.
No description provided.