Recitation 4 should be submitted following directions at:
submissions with deadlines
|
The Fibonacci Numbers: F0 = 0 F1 = 1 Fn = Fn-1 + Fn-2, n > 1 |
The Leonardo Numbers: A0 = 1 A1 = 1 An = An-1 + An-2 + 1, n > 1 |
An = 2 * Fn+1 - 1 |
Note: The following kind of proof is NOT what you are to do:
"Based on the variable y, this program will clearly iterate y times. Each time, starting with 0, we keep adding x to a running sum. In the end, we've added in x a total of y times, so x + x + ... + x (y times) is obviously x*y, which is what mult is supposed to do."
// mult: inputs X and Y both > 0 int mult(int X, int Y) { int x = X, y = Y, p = 0; while (y > 0) { p = p + x; y = y - 1; } return p; } |
|
![]() Click picture or here for full size picture. |