Bash Shell-Fibonacci Series


Simple Bash Shell-Fibonacci Series


if [ $# -eq 1 ]
then
    Num=$1
else
    echo -n "Enter a Number :"
    read Num
fi

f1=0
f2=1

echo "The Fibonacci is : "

for (( i=0;i<=Num;i++ ))
do
     echo -n "$f1 "
     fn=$((f1+f2))
     f1=$f2
     f2=$fn
done


echo

Output
Enter a Number :5
The Fibonacci is :0 1 1 2 3

Comments

Popular posts from this blog

Introduction to C++ Programming Language

The Assembly Process Of 8086 Microprocessor-Two Pass Assembling Steps

Installing 8086 Assembler on a Computer