CSC 175 - Intermediate Programming

Dr. R. M. Siegfried

Assignment #25 - Writing a Recursive Program

Due Wednesday, May 8, 2024

Imagine a recursive f(x) defined as:

   
   f(x) = f(-x)        if x < 0
        = 4*f(x-1) + 3 if x > 1
        = 12           if x = 1
        =  5           if x = 0
   

Implement f(x), assuming that the parameter and the result are both integer. Write a driver for it that test it with both positive and negative values (at least 4 cases).

[Back to the Assignments List]