clone-shim/examples/fib/main.rs
Jake Hillion 9fe48a7749
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
fib example
2022-05-20 18:09:51 +01:00

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
}