Hey, I just had an exam on recursion and the question was much harder than I anticipated. It asked us to write a function called cutAfter7 that "cuts" a number at the first 7 in its digits. If the number is negative or does not contain a 7, the number is outputed as it is.
Here are a few examples of how the function is called and what the function would output:
What really confused me was how I could go about returning a number like 666 if each recursive call was testing the number (x/10) meaning I would not have access to the original (unchanged) number. Maybe I'm just over-analyzing and it's not hard at all? I'd love to hear your comments.