Clean up and rearrange
This commit is contained in:
7
fib_test/rust_fib/Cargo.lock
generated
Normal file
7
fib_test/rust_fib/Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "rust_let"
|
||||
version = "0.1.0"
|
||||
8
fib_test/rust_fib/Cargo.toml
Normal file
8
fib_test/rust_fib/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "rust_let"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
18
fib_test/rust_fib/src/main.rs
Normal file
18
fib_test/rust_fib/src/main.rs
Normal 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()));
|
||||
}
|
||||
Reference in New Issue
Block a user