Give a decimal number, such as
123. Need to figure out all smaller numbers lesser than
123 made up by
0 composed of decimal numbers such as
111, 110, 101, 100, 11, 10, 1, 0.
I am thinking of below recursive solution:
a. If the first number is
1 then we can append
1 to it. Vice versa is true for
0 if it is the first number.
b. In every step check the formed number if it is lesser than the given number. If it is greater than given number then abandon that path.
This way we can find all combinations. However, would this solution be optimal or there is some hidden mathematical logic to this problem?