Question: Part IV: Recursive Number Patterns (4 points) Complete the pattern ) function, which takes a single positive (non-zero) integer as its argument. This function returns

Part IV: Recursive Number Patterns (4 points) Complete the pattern ) function, which takes a single positive (non-zero) integer as its argument. This function returns a new string containing a specific pattern of 1 or more integers, each separated by a single space: If the user enters 1, the program should return "I" If the user enters 2, the program should return "121" If the user enters 3, the program should return "121312 etc. If the pattern isn't obvious from the examples above, the base case occurs when the argument is 1, which returns " The recursive case (when the argument n is greater than 1) surrounds the current value of n with the results of calling the function with the value (n- 1). For example, pattern (2) ultimately returns "12 1" by calling pattern ( 1 ) , followed by "2", followed by calling pattern (1) again Don't worry ifyour function's return value contains one or more extra leading or trailing spaces, as long as there are no double spaces between any of the integers Examples: Function Call Return Value pattern (1)1 pattern (3) 1 21 3 1 21 pattern (5) 1 2 1 31 21 41 2 1 3 1215 1 21 31 21 4121 3 12 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
