Just a fun puzzle that occurred to me. Given the function below which converts decimal integers to binary strings, is it possible to predict which decimal numbers will lead to binary strings with no zeros?
I.e. is there a way to ensure this function only returns strings of 1s without building the string and checking?
std::string toBinary(int n){
std::string r;
while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
return r;
}