How to turn a while loop searching for an element in a set into a recursive function

48 Views Asked by At

I have been recently trying to make a Generalized Factorial Notation and I have run into a problem.

You see, one of the ways to deal with multiple factorials in the input is to examine them one by one from left to right.

In order to do this, we would need to loop through the input until we find a factorial, then do something.

But then to do this, we would need to have a while loop. I decided that I could turn the while loop to recursive function, but I didn’t know how.

So how you turn the pseudo code into a recursive function?

i = 0
input = some set here
while i < length(input):
     if input(i) = factorial:
          break from the loop
     else:
          move on