Algorithm
Step 1 : Start
Step 2 : Read number of terms as n
Step 3 : Initialize 0 to f1, 1 to f2 and 2 to i
Step 4 : Print initial fibonacci terms f1, f2
Step 5 : Generate next term using the formula f3 = f1 + f2
Step 6 : Print f3
Step 7 : Increment i by 1
Step 8 : Assign f2 to f1
Step 9 : Assign f3 to f2
Step 10 : Repeat steps 5–9 until i n
Step 11 : Stop
Program (fibo.sh)
# Fibonacci series using while loop
echo -n "Enter number of terms : "
read n
echo "Fibonacci Series"
f1=0
f2=1
echo -n "$f1 "
echo -n " $f2 "
i=2
Step 1 : Start
Step 2 : Read number of terms as n
Step 3 : Initialize 0 to f1, 1 to f2 and 2 to i
Step 4 : Print initial fibonacci terms f1, f2
Step 5 : Generate next term using the formula f3 = f1 + f2
Step 6 : Print f3
Step 7 : Increment i by 1
Step 8 : Assign f2 to f1
Step 9 : Assign f3 to f2
Step 10 : Repeat steps 5–9 until i n
Step 11 : Stop
Program (fibo.sh)
# Fibonacci series using while loop
echo -n "Enter number of terms : "
read n
echo "Fibonacci Series"
f1=0
f2=1
echo -n "$f1 "
echo -n " $f2 "
i=2