Every positive integer divide some number whose representation (base 10) contains only zeroes and ones.
One can prove that:
Consider the numbers 1, 11, 111,
My algorithm will be :-
1)Construct the sorted tree of of n possible numbers(say n initially is 10). So in this example it will contain 1,10,11,100,101,110,111....
2)Then loop over the list and perform on each no x%GivenNo, if its o its smallest possible no
3)Otherwise repeat step 3 with another 10 numbers