1, so the only numbers it can produce are 1, 11, 111, 1111, and so on.
Given a positive integer divisor, find the shortest of these numbers that is divisible by divisor and return how many digits it has. If no ones-only number is divisible by divisor, return -1.
Keep in mind that the number itself can be huge, far too long to fit in a 64-bit integer.divisor=7 → 6
111111 = 7 × 15873, while none of the shorter ones-only numbers (1, 11, 111, 1111, 11111) is divisible by 7. The length is 6.
divisor=5 → -1
A ones-only number always ends in 1, so it is never divisible by 5.
divisor=37 → 3
111 = 3 × 37, so the answer is 3.
divisor=7
6
Run checks the first 3 tests in your browser. Submit checks all 88 tests on the server, hidden ones included.