Created
February 1, 2024 20:50
-
-
Save Nate-Wilkins/faacb0aa3a4e3bf56292f5b7486aaad7 to your computer and use it in GitHub Desktop.
fibonacci.rs
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 main() { | |
println!("{}", fibonacci(0)); | |
println!("{}", fibonacci(1)); | |
println!("{}", fibonacci(2)); | |
println!("{}", fibonacci(30)); | |
} | |
fn fibonacci(n: u64) -> u64 { | |
match n { | |
0 => 1, | |
1 => 1, | |
n => fibonacci(n - 1) + fibonacci(n - 2) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment