|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Homework & Coursework Questions Students must use and complete the template provided. If you don't, your post may be deleted! Special homework rules apply here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with shell script to find sum of first n numbers of Fibonacci series
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Shell script to find sum of first n numbers of Fibonacci series 2. Relevant commands, code, scripts, algorithms: Code:
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 3. The attempts at a solution (include all code and scripts): Code:
# 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
exit4. 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). Last edited by DukeNuke2; 03-28-2010 at 08:41 AM.. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell script to find the sum of first n Fibonacci numbers | Kshitija | Shell Programming and Scripting | 1 | 03-28-2010 07:49 AM |
| Shell script to generate Fibonacci series using recursion | Tapas Bose | Shell Programming and Scripting | 10 | 12-09-2009 01:05 PM |
| problem in fibonacci series | janani_kalyan | Shell Programming and Scripting | 4 | 02-05-2009 04:25 PM |
| Fibonacci series | nycol | Shell Programming and Scripting | 16 | 04-03-2006 01:21 AM |
|
|