renaming, nothing fancy
This commit is contained in:
parent
4c8ea45113
commit
a1828f53eb
18 changed files with 0 additions and 0 deletions
38
08-fibonacci/src/main.rs
Normal file
38
08-fibonacci/src/main.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
use std::io;
|
||||
fn get_input()->u32
|
||||
{
|
||||
loop
|
||||
{
|
||||
let mut input = String::new();
|
||||
io::stdin()
|
||||
.read_line(&mut input)
|
||||
.expect("Failed to read line");
|
||||
match input.trim().parse()
|
||||
{
|
||||
Ok(num) => return num,
|
||||
Err(_) =>
|
||||
{
|
||||
println!("Expected Valid Number");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
fn fibo(val:u32)->u128
|
||||
{
|
||||
let mut a = 0;
|
||||
let mut b = 1;
|
||||
let mut c;
|
||||
for _element in 2..=val
|
||||
{
|
||||
c = a+b;
|
||||
a = b;
|
||||
b = c;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
fn main()
|
||||
{
|
||||
println!("Hello, world!");
|
||||
println!("Give a Number for Fibonacci Calculation ↓");
|
||||
println!("Result = {}",fibo(get_input()));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue