Fibonacci Sequence. The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it.
/* This program is for printing series of first 'N' (user given limit) Fibonacci Numbers on the console */usestd::io;pubfnfibonacci(){println!("\n Please enter the quantity of Fibonacci number series\n");letmut num =String::new();io::stdin().read_line(&mut num).expect("no data is given");let num :u32= num.trim().parse().unwrap();letmut first :usize=0;letmut second :usize=1;letmut initial :usize=0;letmut next :usize;println!("\n The following is the Fibonacci series\n");println!(" **************************************\n");// for first N Fibonacci Series, we used 0..num Range pattern with num excluding
for _x in0..num {if initial <=1{
next = initial;
initial=1+initial;}else{
next = first + second;
first = second;
second = next;}println!(" Number-{} : {}, \n",_x+1, next);}}