I came across this question in an interview. Any number with 3 in its units position has at least one multiple containing all ones. For instance, a multiple of 3 is 111, a
The multiple of 23 is 1111111111111111111111
#include
int
main () {
unsigned int ones = 1;
double result, by = 23, dividend = 1;
while (dividend) {
result = dividend / by;
if (result < 1) {
dividend = dividend * 10 + 1;
++ones;
} else {
dividend -= by * (int)result;
}
}
while (ones--) {
printf("1");
}
printf("\n");
return 0;
}