Saturday, 16 July 2016

Write a shell script in Linux/Unix to generate Fibonacci series.


tput clear
echo enter the range of the fibonacci series----
read n
echo -------------------------------------------------
a=0
b=1

i=2
echo $a
echo $b
while test $i -lt $n
do

c=`expr $a + $b`
echo $c
a=$b
b=$c
i=`expr $i + 1`
done


OUTPUT:

enter the range of the fibonacci series----
9
-------------------------------------------------
0
1
1
2
3
5
8
13
21











No comments:

Post a Comment

Popular Posts