mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-05-15 15:16:51 +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
|
// ANCHOR: fib
|
||||||
fn fib(n: u32) -> u32 {
|
fn fib(n: u32) -> u32 {
|
||||||
// ANCHOR_END: fib
|
// ANCHOR_END: fib
|
||||||
if n < 2 {
|
if n <= 2 {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return fib(n - 1) + fib(n - 2);
|
return fib(n - 1) + fib(n - 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user