Using only recursion, create a function pattern() that:
• Takes an input of an integer, n
• Based on the integer input, n, the following pattern should be produced as output:
n, n - 10, n - 20, ..., 0, 10, 20, ..., n - 20, n - 10, n
Essentially, you will start by printing out the value n and recursively subtract 10 from
your value until the value is less than or equal to 0. Then begin to add 10 back to your
value until you return to value n.
Example Output #1
pattern (50, ...)
50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50
Example Output #2
pattern (27, ...)
27, 17, 7, -3, 7, 17, 27
Example Output #3
pattern (0, ...)
0, -10, 0
Notes:
• You will need more than one parameter to initiate this function, hence the "..." in the
example output. I leave it up to you to determine additional parameters you should
include (it should be no more than three parameters in total)
• No use of for-loops, while-loops, etc.
Hint: You may find using a sentinel variable as one of the input parameters in the
pattern() function to help enter the 'base case' of your recursion.