cs102 lab4


http://www.maths.nuigalway.ie/~gettrick/teach/cs102/labs/l4.html




The Fibonacci Numbers (or sequence) are defined by setting the first two numbers equal to one, and each successive number equal to the addition (sum) of the previous two numbers. In other words, f1=1, f2=1, fi= fi-1+fi-2, so we get the sequence 1, 1, 2, 3, 5, 8, 13, 21,.... Write a program in PYTHON to calculate the nth Fibonacci Number, using

  1. Iteration
  2. Recursion
(You should submit your two programs as separate attachments in the BLACKBOARD upload page).

© NUI, Galway