Custom Search

Friday 20 April 2012

Write a Linux shell script to generate fibonacci number from 1 to n, Unix program for fibonacci series


Write a Linux shell script to generate fibonacci number from 1 to n, Unix program for fibonacci series


Program
clear
echo "Enter the number upto which you want series :"
read n


n1=0
n2=1
echo $n1
echo $n2


for ((i=0;i<n;i++))
do
  n3='expr $n1 + $n2 '
  echo$n3
  n1= $n2
  n2= $n3
 done


Output:
Enter the number upto which you want series :
5


0
1
1
2
3
5
<<< Previous  ||  Current  ||  Next >>>  

No comments:

Post a Comment

Laptops