Skip to content

Instantly share code, notes, and snippets.

@rtacconi
Last active July 14, 2017 17:48
Show Gist options
  • Save rtacconi/cf4c07bef29a3a6c6aba7c13b1d3a331 to your computer and use it in GitHub Desktop.
Save rtacconi/cf4c07bef29a3a6c6aba7c13b1d3a331 to your computer and use it in GitHub Desktop.
Calculation of fibonacci number with Rust
fn fib(x: u64) -> u64 {
if x > 1 { fib(x - 1) + fib(x - 2) } else { x }
}
fn main() {
println!("Result {}", fib(10)); // -> 55
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment