Write a C++ program that recursively computes each term of G(n) up to and including a given
Fantastic news! We've Found the answer you've been seeking!
Question:
Write a C++ program that recursively computes each term of G(n) up to and including a given n . You can "hard code" the input value (the program does not need to accept any input) but you will need to set it sufficiently high so you can determine your answer for the second part below -- you may need to experiment with different values.
The formula is:
G(n) = 1 + G(n - G(G(n - 1)))
Remember to think about the base case.
Example Output
The output of your program does not need to exactly match this, but please make sure each term is output on a separate line along with the n for that term.
For n = 15:
1: 1 2: 2 3: 2 4: 3 5: 3 6: 4 7: 4 8: 4 9: 5 10: 5 11: 5 12: 6 13: 6 14: 6 15: 6
Related Book For
Digital Signal Processing
ISBN: ?978-0133737622
3rd Edition
Authors: Jonh G. Proakis, Dimitris G.Manolakis
Posted Date: