Skip to content

Instantly share code, notes, and snippets.

@epequeno
Created November 28, 2016 11:06
Show Gist options
  • Save epequeno/d5e185391b3a0ddba7d6a06023ec6d6d to your computer and use it in GitHub Desktop.
Save epequeno/d5e185391b3a0ddba7d6a06023ec6d6d to your computer and use it in GitHub Desktop.
fibo in rust
fn main() {
for x in 1..11 {
println!("{} -> {}", x, fibo(x));
}
}
fn fibo(n: i32) -> f64 {
let phi = (1_f64 + 5_f64.sqrt()) / 2_f64;
(phi.powf(n as f64) / 5_f64.sqrt()).round()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment