Project: Fibonacci Numbers
You can compute numbers in the [[Fibonacci_number|Fibonacci Sequence]] easily using function recursion. The Fibonacci Sequence is specified by the recurrence relation...
`F_n = F_n-1 + F_n-2` for n > 1
with `F_0` = 1 and `F_1` = 1
Write a [[Recursion_(computer_science)|recursive function] to compute Fibonacci numbers given n. Write a main program to test the function.
Output
$ rustc Fibonacci1.rs
error: unknown format trait `d`
--> Fibonacci1.rs:21:31
|
21 | println!("{}", format!("{0:d}: {1:d}", n, fibonacci(n)));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error: unknown format trait `d`
--> Fibonacci1.rs:21:38
|
21 | println!("{}", format!("{0:d}: {1:d}", n, fibonacci(n)));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error: aborting due to 2 previous errors