We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cc5ef88 commit 06ed8d8Copy full SHA for 06ed8d8
1015.cpp
@@ -0,0 +1,37 @@
1
+class Solution {
2
+public:
3
+ int smallestRepunitDivByK(int K) {
4
+
5
+ if(K%2==0){
6
+ return -1;
7
+ }
8
+ if(K%5==0){
9
10
11
+ if(K==1){
12
+ return 1;
13
14
15
+ int n=1;
16
+ int remainder=1;
17
18
+ int count=1;
19
20
+ while(remainder!=0){
21
22
+ remainder=remainder*10 + 1 ;
23
+ remainder=remainder%K;
24
+ count++;
25
26
+ if(remainder==0){
27
+ return count;
28
29
30
31
32
33
34
35
36
37
+};
0 commit comments