Problem 57555. Easy Sequences 91: Generalized McCarthy-91 Recursive Function
The McCarthy 91 function is a recursive function, defined by the computer scientist John McCarthy as a test case for formal verification within computer science.
The McCarthy 91 function is defined for integer n as:
Remarkably, the function yields
for all
(hence, the function name).
A more generalized form of the McCarthy's recursive function is defined below:
For positive integers a, b, c, k, and n.
The expression
, means applying the function G, k number of times:
This means that the 'original' McCarthy-91 function
is actually
, with
,
,
and
.
Given integers, a, b, c, k, and n, evaluate the value of
.
--------------------
NOTE: The McCarthy-91 function was created to test recursive function implementations. In this problem, while iterative loops are allowed, use of recursion is encouraged.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers2
Suggested Problems
-
9936 Solvers
-
Back to basics 11 - Max Integer
779 Solvers
-
Generate a random matrix A of (1,-1)
310 Solvers
-
07 - Common functions and indexing 5
405 Solvers
-
Area of an equilateral triangle
6030 Solvers
More from this Author116
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!