cs102 lab8
http://www.maths.nuigalway.ie/~gettrick/teach/cs102/labs/l8.html
-
For this lab you must submit all source code (python
files), and, if applicable, the result(s) of running the program on (a few)
test cases. This should be sent in via BLACKBOARD (not directly by email).
The source code must
be well presented (indenting, spaces, reasonable variable/function names,
etc.) and must include comments (as a rough guideline - aim to have nearly as
many comments as lines of code). Any questions asked should be answered by
typing the answers into the relevant box on the BLACKBOARD upload form.
-
This material should be uploaded
before
the deadline of 5pm
Friday March 23rd, 2012. You will lose 20% for each day
(or part of day) the lab is late.
-
Plagiarism (the unattributed copying of work from other sources
(internet, fellow students,....)) will not be tolerated. Please see
http://www.nuigalway.ie/engineering/documents/plagiarism_guide_students
_v4.pdf. You risk getting zero for your lab if it is found to be
plagiarized.
Please first study the program fibBIN.py which is at
http://www.maths.nuigalway.ie/~gettrick/teach/cs102/progs/ (This program was handed out and covered during lectures. It uses the idea of binary powering of a
matrix to calculate the Fibonacci numbers.)
Suppose we define the Fibolucci numbers by
f0=0,
f1=1,
f2=1,
and in general
fn+1 = fn + fn-1 + fn-2
for n greater than 1.
So, the sequence goes
0, 1, 1, 2, 4, 7, 13, 24, 44, 81,...
Use the idea of Binary Powering covered in lectures to write a
python program which can calculate the nth Fibolucci number
(the number n should be read in from the user).
You must not use recursion.
Test your program by calculating
-
The 47th Fibolucci number
-
The 132nd Fibolucci number
And submit these results with your program.
©
NUI, Galway