Originally posted by whatman
The answers I am getting from the program are -4, -11, -10 and 13 for n = 3 to 6 and my answers from working them out are-4, -29, -192 and -419.
Are you sure that the answers you are working out are correct?
Code:
A(0) = 1, A(1) = 2, A(n) = 2A(n-1) - 3A(n-2) for n > 1 :
A(2) = 2 * A(1) - 3 * A(0) = 2 * ( 2) - 3 * ( 1) = 4 - 3 = 1
A(3) = 2 * A(2) - 3 * A(1) = 2 * ( 1) - 3 * ( 2) = 2 - 6 = -4
A(4) = 2 * A(3) - 3 * A(2) = 2 * ( -4) - 3 * ( 1) = -8 - 3 = -11
A(5) = 2 * A(4) - 3 * A(3) = 2 * (-11) - 3 * ( -4) = -22 - -12 = -10
A(6) = 2 * A(5) - 3 * A(4) = 2 * (-10) - 3 * (-11) = -20 - -33 = 13