I’m trying to figure out how to write a code which takes an input from 0 to any positive integer, that will return a string of 0 for when zero is entered, 10 when 1 is entered, 1110 for when 2 is entered, 3110 for when 3 is entered and so on, this is saying that when input 0 occurs output is 0, then when 1 is input it looks at the input for 0 and reads it as ‘one zero’ and prints 10, the for 2 reads input 1 as ‘one one and one zero’ and prints 1110, and so on and so forth. I have an idea of what to do but it’s too vague to translate into code. When I posted this I didn’t know what it was called but since then I found that it was the look and see sequence, and my issue is that I can’t use iteration, nor can I use the built-in len() or string.append() function.
Share
If you can’t use any iteration, then you need to use recursion with a stop at 0. It will look something like this: