Untitled

 avatar
unknown
plain_text
9 months ago
404 B
9
Indexable
# Program for Fibonacci Series

# Take input for N from the user
read -p "Enter the number of terms for Fibonacci series: " N

# First Number of the Fibonacci Series
a=0

# Second Number of the Fibonacci Series
b=1

echo "The Fibonacci series is: "

for (( i=0; i<N; i++ ))
do
    echo -n "$a "
    fn=$((a + b))
    a=$b
    b=$fn
done

echo  # To print a newline after the series
Editor is loading...
Leave a Comment