SHELL PROGRAM
Write a program to display fibonacci series within a limit ? | Shell Program |
#!/bin/bash
echo "Enter the limit"
read n
x=0
y=1
i=2
echo "Fibonacci series upto $n terms"
echo "$x"
echo "$y"
while [ $i -lt $n ]
do
i=`expr $i + 1`
z=`expr $x + $y`
echo "$z"
x=$y
y=$z
done
OUTPUT
Enter the limit
10
Fibonacci series upto 10 terms
0
1
1
2
3
5
8
13
21
34
echo "Enter the limit"
read n
x=0
y=1
i=2
echo "Fibonacci series upto $n terms"
echo "$x"
echo "$y"
while [ $i -lt $n ]
do
i=`expr $i + 1`
z=`expr $x + $y`
echo "$z"
x=$y
y=$z
done
OUTPUT
Enter the limit
10
Fibonacci series upto 10 terms
0
1
1
2
3
5
8
13
21
34
Post a Comment
0 Comments