The Pell numbers are an infinite sequence of integers, which are the denominators of the closest rational approximations to the square root of 2. This sequence of approximations begins 1/1, 3/2, 7/5, 17/12, and 41/29.
This sequence of numbers:
(0, 1, 2, 5, 12, 29, 70, 169, 408, 985, 2378, 5741, 13860, 33461, ...)
can be computed with the following recursive function:
Pn = {
0 : if n = 0
1 : if n = 1
2 * Pn-1 + Pn-2 : otherwise
}
In SPIM, you will write the function int pell(int N) described above. N comes from the argument passed in register $a0. Your function returns the value in $v0.
Note that pell(0) = 0, pell(1) = 1, pell(2) = 2, pell(3) = 5, pell(4) = 12, ..., pell(10) = 2378. Ensure you are not off by 1 in the sequence!
Your program will prompt the user for a value of N. Your program will read in this integer N from the user and call your function pell(N). Your program will then print out the result.