17 lines
255 B
Rust
17 lines
255 B
Rust
fn main() {
|
|
println!("fib(1) = {}", fib(1));
|
|
println!("fib(7) = {}", fib(7));
|
|
println!("fib(19) = {}", fib(19));
|
|
}
|
|
|
|
fn fib(i: u64) -> u64 {
|
|
let mut a = 0;
|
|
let mut b = 1;
|
|
|
|
for _ in 0..i {
|
|
(a, b) = (b, a + b);
|
|
}
|
|
|
|
a
|
|
}
|