Docsity

Creating the Fibonacci Sequence Programming Project | CSC 1253, Study notes of Computer Science

Toggle sidebar
bg1
Iteration CSc 1253: Project # 3
Computing a Fibonacci Series
Out: 2/14
Due: 3/2 by 11:50 PM
Learning Objectives
•Using Iteration
•More on Writing Interactive Programs
Definition 1. The Fibonacci numbers are the numbers in the following
integer sequence: 0,1,1,2,3,5,8,13,21,34,55,. . . .
By definition, the first two Fibonacci numbers are 0 and 1, and each sub-
sequent number is the sum of the previous two. In mathematical terms,
the sequence Fkof Fibonacci numbers is defined by the recurrence relation
F1= 0, F2= 1, and Fk=Fk−1+Fk−2,k > 2.
Sample Run 1:
Enter the number of terms in the Fibonacci series>1
F[1] = 0
Sample Run 2:
Enter the number of terms in the Fibonacci series>2
F[2] = 0 + 1 = 1
Sample Run 3:
Enter the number of terms in the Fibonacci series>4
F[4] = 0 + 1 + 1 + 2 = 4
Sample Run 4:
Enter the number of terms in the Fibonacci series>8
F[8] = 0 + 1 + 1 + 2 + 3 + 5 + 8 + 13 = 33
Be sure to use descriptive names for all identifiers you define in your program.
Follow the C++ Coding Style Guidelines we discussed in class. Name your
source file fibseries.cpp.
Duncan 1 Spring 2011
pf2

Partial preview of the text

Download Creating the Fibonacci Sequence Programming Project | CSC 1253 and more Study notes Computer Science in PDF only on Docsity!

Iteration CSc 1253: Project # 3

Computing a Fibonacci Series

Out: 2/ Due: 3/2 by 11:50 PM

Learning Objectives

  • Using Iteration
  • More on Writing Interactive Programs

Definition 1. The Fibonacci numbers are the numbers in the following integer sequence: 0,1,1,2,3,5,8,13,21,34,55,....

By definition, the first two Fibonacci numbers are 0 and 1, and each sub- sequent number is the sum of the previous two. In mathematical terms, the sequence Fk of Fibonacci numbers is defined by the recurrence relation F 1 = 0, F 2 = 1, and Fk = Fk− 1 + Fk− 2 , k > 2.

Sample Run 1: Enter the number of terms in the Fibonacci series> F[1] = 0

Sample Run 2: Enter the number of terms in the Fibonacci series> F[2] = 0 + 1 = 1

Sample Run 3: Enter the number of terms in the Fibonacci series> F[4] = 0 + 1 + 1 + 2 = 4

Sample Run 4: Enter the number of terms in the Fibonacci series> F[8] = 0 + 1 + 1 + 2 + 3 + 5 + 8 + 13 = 33

Be sure to use descriptive names for all identifiers you define in your program. Follow the C++ Coding Style Guidelines we discussed in class. Name your source file fibseries.cpp.

Duncan 1 Spring 2011

Iteration CSc 1253: Project # 3

Your source file must have the following header comments:

/*

  • @file filename
  • @author your name
  • @date 9999-99-
  • Description: describe what the program does.
  • Course: CS1253 Section xx
  • Logon ID: cs1253xx
  • Programming Project #: 3
  • Instructor: Duncan */

Preparing your workspace and submitting Your Work

  1. Logon to the server (classes.csc.lsu.edu) using your logon ID and pass- word.
  2. Create a directory prog3 in your home area: mkdir prog
  3. Change to the prog3 directory: cd prog
  4. Edit your program using pico or your favorite editor: pico fibseries.cpp Save your program (ctrl+o) and exit (ctrl+x) the editor when you are finished.
  5. Compile your program: g++ -o fibseries fibseries.cpp
  6. Correct any syntax and semantic errors you may have. Once your program is free of these errors, run your program to make sure that that your output is formatted as required.
  7. submit your assignment to the grader with the following command: ∼cs1253 dun/bin/p copy 3 This command copies everything in your prog3 directory.
  8. Once p copy is finished, check to see if your files have been submitted: ∼cs1253 dun/bin/verify 3
  9. You may submit your work as many times as you wish once the deadline has not elapsed. Any submission after the deadline means you will get no credit for this project.

Duncan 2 Spring 2011