Timeline for Find the closest Fibonacci Number
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 20, 2017 at 10:59 | comment | added | Nevay | The r>c&&s<c condition is never satisfied if the input is a fibonacci number, thus times out for 1 etc. | |
Jul 20, 2017 at 7:10 | comment | added | 0x45 | @Nevay I don't see the error, I've tested it without fails | |
Jul 19, 2017 at 20:58 | comment | added | Nevay |
You have two errors in your code (r>c&&s<c should be r>=c&&s<=c , s-c should be c-s ), You could remove not required whitespace, use int f(int i){return i<2?i:f(--i)+f(--i);} , use a single return statement with ternary operator in c and remove the special handling for c-s==r-c as returning either value is allowed.
|
|
Jul 19, 2017 at 16:05 | history | edited | 0x45 | CC BY-SA 3.0 |
deleted 1 character in body
|
Jul 19, 2017 at 15:54 | comment | added | Okx |
Why don't you use Java 8 and turn this into a lambda? You can also remove static if you want to stick with Java 7.
|
|
Jul 19, 2017 at 15:51 | history | answered | 0x45 | CC BY-SA 3.0 |