Ones

Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a number which in decimal notation is a sequence of 1's. How many digits are in the smallest such a multiple of n?

Sample Input
3

7

9901

Sample Output
3

6

12

Source Code code format="java5" public class Ones { public static void main(String[] args) { int n = 3; System.out.println(one(n));

n = 7; System.out.println(one(n));

n = 9901; System.out.println(one(n)); }

public static int one(int n) { long i = 1;

while((i % n) != 0) { i *= 10; i += 1; }

int c = 0;

while(i != 0) { i /= 10; c++; }

return c;   } } code

Comment