Shell Script to generate fibonacci series - The Coding Shala

Home >> Scripting >> Fibonacci Series

Shell Script to generate Fibonacci series

Write a shell script to generate and display the Fibonacci series?

Code: 

#!/bin/bash
c=2
a=1
b=1
d=0
echo  "enter the number of elements"
read n
echo "$a"
echo "$b"
while((c<n))
do
d=$((a+b))
echo "$d"
a=$b
b=$d
c=$((c+1))
done



Other Posts You May Like
Please leave a comment below if you like this post or found some error, it will help me to improve my content.

Comments

Popular Posts from this Blog

Binary Number with Alternating Bits LeetCode Solution - The Coding Shala

Time Complexity, Space Complexity, Asymptotic Notations - The Coding Shala

Java Program to Reverse a String using Stack - The Coding Shala

Java Program to Find GCD or HCF of Two Numbers - The Coding Shala

Java Method Overloading - The Coding Shala