clone-shim/examples/fib/main.rs
Jake Hillion 7bf1b6600d
All checks were successful
continuous-integration/drone/push Build is passing
fib decl one line
2022-05-22 19:15:16 +01:00

16 lines
250 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, mut b) = (0, 1);
for _ in 0..i {
(a, b) = (b, a + b);
}
a
}