CSCI 116

Project #8: Recursion

 

Your math major friend just heard about something called Fibonacci numbers and thinks the idea is cool.  He is trying to generalize the concept and has decided to look at the sequence where

 

 

He wants you to compute the first k terms of the sequence, where k is specified by him.

 

Here is a sample output:

 

Z:\Spring 2015\CSCI 116>sequence 7

0, 1, 2, 5, 12, 29, 70

 

Press any key to continue...

 

Z:\Spring 2015\CSCI 116>

 

Notice that your program has printed out a comma separated list of the first seven numbers of the sequence, counting the 0 and the 1.

 

(Unfortunately for your friend, he hasn’t discovered something new, he has rediscovered what are called the Pell numbers.  Among other things, these are denominators of the closest rational approximations to the square root of 2, while the numerators of these approximations are the sum of a Pell number and its predecessor in the sequence, or ½ the values of the companion Pell numbers.  The sequence of approximations is 1, 3/2, 7/5, 17/12, 41/29, 99/70, …)

 

If the formula is not showing up in this page, then check the PDF of it.