How to find the smallest number with just 0 and 1 which is divided by a given number?

后端 未结 11 1361
情话喂你
情话喂你 2020-11-29 22:44

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,

11条回答
  •  孤城傲影
    2020-11-29 23:20

    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

提交回复
热议问题