java solution
\nclass Solution {\n    public int smallestRepunitDivByK(int k) {\n        int n=0;\n        if(k%2==0 || k%5==0)\n            return -1;\n        int i=1;\n   
```\nclass Solution {\n    public int smallestRepunitDivByK(int k) {\n        int n=0;\n        if(k%2==0 || k%5==0)\n            return -1;\n        int i=1;\n        while(i<=k){\n            n=(n*10+1)%k; /*its used to get next remainder*/\n            if(n==0){\n                return i;\n            }\n            i++; /*counting length of n*/\n        }\n        return -1;\n    }\n}\n```
['Java']