Code In Tech - The Ultimate World of Computer Technology

Saturday, 12 May 2012

Shell script to print the fibonaci series up to given no.

SOURCE CODE:

echo “Enter the no.:“
read n
i=0
j=1
k=1
echo $i
while [ $j –le -$n ]
do
     echo $k
     k=`expr $j + $i`
     i=$j
     j=$k
done

OUTPUT:
  
Enter the no.:
8
0
1
1
2
3
5

No comments :

Post a Comment