mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-12-15 06:20:32 +02:00
Fix Fibonacci numbers example (#1529)
The exercise has n <= 2 for the base case, but it is n < 2 in the solution. You currently get fib(n) = 10946 for n = 20, but it should be 6765.
This commit is contained in:
parent
9905b21c26
commit
1ba88ba72e
@ -16,7 +16,7 @@
|
||||
// ANCHOR: fib
|
||||
fn fib(n: u32) -> u32 {
|
||||
// ANCHOR_END: fib
|
||||
if n < 2 {
|
||||
if n <= 2 {
|
||||
return 1;
|
||||
} else {
|
||||
return fib(n - 1) + fib(n - 2);
|
||||
|
Loading…
Reference in New Issue
Block a user