Skip to main content
3 of 4
deleted 76 characters in body
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

#Java 10, 62 59 58 bytes

n->{var r=n;for(;!(r+"").matches("[01]+");)r+=n;return r;} 

Try it online.

Explanation:

n->{ // Method with long as both parameter and return-type var r=n; // Result-long, starting at the input for(;!(r+"").matches("[01]+");) // Loop as long as `r` does NOT consists of only 0s and 1s r+=n; // Increase `r` by the input return r;} // After the loop is done, return `r` as result 

This method above only works for binary outputs \$\leq1111111111111111111\$. For arbitrary large outputs - given enough time and resources - the following can be used instead (99 70 64 bytes):

n->{var r=n;for(;!(r+"").matches("[01]+");)r=r.add(n);return r;} 

Try it online.

Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394