I should start by mentioning that I know Wei Cui posted something that will pass in another person's question, but if I just copy and paste that I won't be learning why my own code is not validating. I can't seem to find any of the listed requirements I'm not in line with, and it works for all values 1 through Integer.MAX_VALUE. The strategy with my code here is: 1. Convert the binary representation to something of the format 0...01...1, where the left-most 1 is the same as the left-most one in number. This is done by number = (number >> 1) | number, 32 times to make sure it covers any binary value. 2. Bitshift left and & 1, so that it's still of the form 0...01...1 but the right-most 0 has been turned into a 1 and the right-most 1 stays a 1. 3. Use ^ operator with that and the previous value 0...01...1, so that you get a number of the form 0...010...0, where the 1 is one place to the left of where it needs to be. 4. Bitshift back to the right to get it in the correct place and use & operator with Integer.MAX_VALUE to prevent the sign from changing ( I didn't use >>> operator here because it's not in the list of allowed operators)