Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
- The problem statement, all variables and given/known data:
Shell script to find sum of first n numbers of Fibonacci series
- Relevant commands, code, scripts, algorithms:
prev=0
next=1
echo $prev
while(true)
do
echo $next
#add the two numbers
sum=$(($prev+$next))
#swap
prev=$next
next=$sum
sleep 1
done
- The attempts at a solution (include all code and scripts):
# Shell scrpt to generate Fibonacci series using recursion
export MINIDX=2
Fibonacci ()
{
idx=$1
if [ "$idx" -lt "$MINIDX" ]; then
echo "$idx"
else
(( --idx ))
term1=$( Fibonacci $idx )
(( --idx ))
term2=$( Fibonacci $idx )
echo $(( term1 + term2 ))
fi
}
echo -n "Enter the number of term : "
read MAXTERM
for (( i=0; i<=$MAXTERM; i++ ))
do
FIBO=$(Fibonacci $i)
echo -n "$FIBO "
done
echo
exit
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
D.G Ruparel College(Mumbai University),Mumbai(Maharashtra),India
Professor Puja Tambe and Computer Science
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).