Rust Fibonacci

Published 361d ago

 nptester

Iterative Fibonacci sequence generator in Rust

fn fibonacci(n: u32) -> u32 {
    let mut a = 0;
    let mut b = 1;
    for _ in 0..n {
        let temp = a;
        a = b;
        b = temp + a;
    }
    a
}

fibonacciiterationRust
1

Please login or sign up to comment and collaborate