A binary multiple of a positive integer k
is a positive integer n
such that n
is written only with 0
s and 1
s in base 10 and n
is a multiple of k
. For example, 111111
is a binary multiple of 3.
It is easy to show that a positive integer has infinitely many binary multiples. See here for a construction proof of one binary multiple for each k
. Multiplying by powers of 10
you get infinitely many more.
Your task
Given a positive integer k
, return the smallest binary multiple of k
.
Input
A positive integer k
.
Output
A positive integer n
, the smallest binary multiple of k
.
Test cases
2 -> 10
3 -> 111
4 -> 100
5 -> 10
6 -> 1110
7 -> 1001
8 -> 1000
9 -> 111111111
10 -> 10
11 -> 11
12 -> 11100
13 -> 1001
14 -> 10010
15 -> 1110
16 -> 10000
17 -> 11101
18 -> 1111111110
19 -> 11001
20 -> 100
100 -> 100
This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it... And happy golfing!
This is the first challenge of the RGS Golfing Showdown. If you want to participate in the competition, you have 96 hours to submit your eligible answers. Remember there is 450 reputation in prizes! (See 6 of the rules)
Otherwise, this is still a regular code-golf challenge, so enjoy!