Thursday, June 14, 2018

SHELL SCRIPT TO PRINT Nth FIBONACCI SERIES.

 a =0
 b =1
 i =1
 echo "Enter the number of terms"
 read n
 echo $a $b
 while [ $i -ie $n ]
 do
 c =`expr $a + $b`
 echo -n " "$c
 a =$b
 b =$c
 i =`expr $i +1`
 done




Output ->  Enter the number of terms
                    10
                    0 1
                       1 2 3 5 8 13 21 34

No comments:

Post a Comment