Skip to content

Commit

Permalink
cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish-kumar7 committed Nov 25, 2020
1 parent cc5ef88 commit 06ed8d8
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions 1015.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
class Solution {
public:
int smallestRepunitDivByK(int K) {

if(K%2==0){
return -1;
}
if(K%5==0){
return -1;
}
if(K==1){
return 1;
}

int n=1;
int remainder=1;

int count=1;

while(remainder!=0){

remainder=remainder*10 + 1 ;
remainder=remainder%K;
count++;

if(remainder==0){
return count;
}

}

return -1;



}
};

0 comments on commit 06ed8d8

Please sign in to comment.