BKJIA Translation: It feels great when you understand Shell scripts and can write them smoothly whenever needed. In this chapter, we will teach you how to use scripting to perform complex mathematical operations.
 
Let's start with the Fibonacci series.
 
The Fibonacci series, also known as the Golden split series, refers to a series of 0, 1, 1, 2, 3, 5, 8, 13, 21 ......, Each of its items is the sum of the first two items, and the first two items of the defined series are 0 and 1.
 
Script 1: maid. sh
 
#!/bin/bashecho "How many numbers do you want of Fibonacci series ?"   read total   x=0   y=1   i=2   echo "Fibonacci Series up to $total terms :: "   echo "$x"   echo "$y"   while [ $i -lt $total ]   do       i=`expr $i + 1 `       z=`expr $x + $y `       echo "$z"       x=$y       y=$z   done
 
Sample output
 
[root@tecmint ~]# chmod 755 Fibonacci.sh[root@tecmint ~]# ./Fibonacci.shHow many numbers do you want of Fibonacci series ? 10 Fibonacci Series up to 10 terms :: 0 1 1 2 3 5 8 13 21 34
 
DownloadFibonacci. sh