Add rust example

This commit is contained in:
Nathan Braswell
2022-04-11 16:07:11 -04:00
parent 645b9f7172
commit 55afa8977e
5 changed files with 73 additions and 18 deletions

18
rust_fib/src/main.rs Normal file
View File

@@ -0,0 +1,18 @@
use std::io;
fn fib(n: i64) -> i64 {
match n {
0 => 1,
1 => 1,
o => fib(o-1) + fib(o-2),
}
}
fn main() {
println!("enter number to fib:");
let mut buffer = String::new();
let stdin = io::stdin();
stdin.read_line(&mut buffer).unwrap();
println!("{}", fib(buffer.trim().parse::<i64>().unwrap()));
}