Last active
July 14, 2017 17:48
-
-
Save rtacconi/cf4c07bef29a3a6c6aba7c13b1d3a331 to your computer and use it in GitHub Desktop.
Calculation of fibonacci number with Rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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