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"











Comments

Popular posts from this blog

Write a Program to Add two 3x3 Matrix using C

C program for Unit Conversion

Write a Program to Add two 5x5 Matrix using C