**ZeroOne** is the number, whose digits are either *0* or *1*. You have given a number *n* and need to find the smallest multiplier which is **ZeroOne** Number

For example for *4* smallest possible ZeroOne Multipler is *100*

**Solution**

I have tried to solve this but really could not find the optimize solution.

#include <stdio.h>
int getZeroOneMultipler(int number) {
long multiplier = 1;
while(1) {
long product = multiplier++ * number;
long temp = product;
while ( temp != 0 ) {
int digit = temp % 10;
if ( digit != 0 && digit != 1 ) {
break;
}
temp /= 10;
}
if ( temp == 0 ) {
return product;
}
}
}
int main(int argc, char** argv) {
int i = 0;
for ( i = 0; i < 100; i++) {
printf("%d = %d\n", i, getZeroOneMultipler(i));
}
return 0;
}

### Like this:

Like Loading...

*Related*

Check this out:

Vishal, thanks, this one is interesting, it cannot find answer for some inputs. just changing variable step and zeroOne to long will give me answer for 99 also.

Thanks Again.

Forgot to mention that the reason for the following line of code:

reason is that a “zero one” number is a “sum of powers of 10” or number in binary form used as a decimal.

Here’s a function to calculate a ZeroOne instead of using parseInt() and toBinaryString()

Amazing solution Vishal