Saturday, 10 November 2012

Write a shell script program to print the fibonacci series

 --Fibonacci Series

echo fibonacci series
echo how many terms u want to print
read n
a=0
b=1
count=0
echo fibbonaci series is
echo $a
echo $b
n=`expr $n - 2`
while [ $count -lt $n ]
do
c=`expr $b + $a`
echo $c
a=`expr $b`
b=`expr $c`
count=`expr $count + 1`
done

No comments:

Post a Comment