#3790

Smallest All-Ones Multiple

specialist · 925 · lc medium +32 · 46.9% accepted · 93 likes · top 31%

Description

Given a positive integer k, find the shortest repunit (a number made entirely of 1s, e.g., 1, 11, 111, ...) that is divisible by k, and return its digit count — or -1 if no such repunit exists.

Code

1
2
3