Here is the problem:
Suppose a sequence is defined recursively be setting and and, for , requiring that .
Give a recursive algorithm for computing , where is a positive integer.
Using the initial conditions, I could calculate , etc., but that is not what the problem is asking for. I thought recursive definitions were when you set , but that makes the equation work with negative numbers. So, here I am, confused beyond belief with algorithms
The program that has been posted is in the computer language C, but it is a very very bad way of calculating the function. For a very similar example, and explanation of why it is bad see
Dr. Dobb's | The Case for D | June 15, 2009
Your teacher probably really does want you to come up with a solution like this, as the exercise is probably to get you familiar with the concept of a recursive function. But functions like this should absolutely not be calculated using recursion.
I'm not saying this the best way and know this algorithm is very bad for computing given function.
But this is the way how to solve given problem in recursive manner.
The program i wrote is in C programming language. I didn't try if it compiles or not.
But i am sure this is the answer.
Are you sure of the wording of the problem?
A sequence is defined recursively by: .
Give a (?) recursive (?) algorithm for computing , where is a positive integer.
By my understanding, they've already given us the recursive algorithm.
. . What they want is a "closed form" for the term.
There is a procedure for determining the generating function for a linear recursion,
. . but I will wait until I get some clarification.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Well, okay . . . Here's the answer:
. . .