Bash shell –lt refers to less than –le indicate less than or equal to using simple mathematical algorithm it will perform the mathematical calculation and display Fibonacci series using Linux and UNIX shell programming . it use echo command to display the result.

Source code bash shell Programming Algorithm

echo "Enter the number"

read n

i=1

a=-1

fib=0

b=1

echo "Fibonacci series is"

while [ $i -lt $n ]

do

fib=`expr $a + $b`

a=$b

b=$fib

echo $fib

i=`expr $i + 1`

done

OUTPUT Find FIBONACCI SERIES CS1252 Operating Systems lap

[redhat35@localhost Rhel5]$ sh fib.sh

Enter the number

8

Fibonacci series is

0

1

1

2

3

5

8

Source code bash shell Programming Algorithm

echo "Enter the number"

read n

i=1

a=-1

fib=0

b=1

echo "Fibonacci series is"

while [ $i -lt $n ]

do

fib=`expr $a + $b`

a=$b

b=$fib

echo $fib

i=`expr $i + 1`

done

OUTPUT Find FIBONACCI SERIES CS1252 Operating Systems lap

[redhat35@localhost Rhel5]$ sh fib.sh

Enter the number

8

Fibonacci series is

0

1

1

2

3

5

8

## 1 comment:

Write comments