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

后端 未结 11 1377
情话喂你
情话喂你 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:32

    I think this is a fair and interesting question.

    Please note that though what you describe is a proof there always exist such number, the found number will not always be minimal.

    Only solution I can think of is to compute the remainders of the powers of 10 modulus the given n and than try to construct a sum giving remainder 0 modulo n using at most one of each of these powers. You will never need more than n different powers(which you prove i your question).

提交回复
热议问题