Skip to content

Instantly share code, notes, and snippets.

@Nate-Wilkins
Created February 1, 2024 20:50
Show Gist options
  • Save Nate-Wilkins/faacb0aa3a4e3bf56292f5b7486aaad7 to your computer and use it in GitHub Desktop.
Save Nate-Wilkins/faacb0aa3a4e3bf56292f5b7486aaad7 to your computer and use it in GitHub Desktop.
fibonacci.rs
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