1
0
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:
J.Lunz 2023-11-30 15:46:13 +01:00 committed by GitHub
parent 9905b21c26
commit 1ba88ba72e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);