Fibonacci Series generator [Shell Program]



echo "Enter the Number of Terms"


read n


a=0


b=1


count=1


n1=`expr $n - 2`


if [ $n -eq 1 ]


then


echo "The
Fibonacci series is:"
$a


elif [ $n -eq 2 ]


then


echo "The
Fibonacci series is:"
$a $b


else


echo "The
Fibonacci series is:"


echo "$a $b
\c"


while [ $count -le $n1 ]


do


c=`expr $a + $b`


echo "$c \c"


a=$b


b=$c


count=`expr $count +
1`


done


fi


echo "\n"











0 Comments