Spotify's "Reversed Binary Numbers" Problem
I do not see any problems inside the given range. I would have used already existing methods:

public static int reverse2(final int n) {
    return Integer.valueOf(new StringBuilder(Integer.toBinaryString(n)).reverse().toString(), 2);
}


Which is probably to best readable version.



If we want to do it by ourself and do not want to create a string and stringbuilder:

With recursion:

public static int reverse3(final int newNumber, final int number) {
    if (number == 0)
        return newNumber;
    return reverse3((newNumber &lt;&lt; 1) | (number &amp; 1), number &gt;&gt; 1);
}


Without recursion:

public static int reverse4(int number) {
    int newNumber = 0;
    while (number != 0) {
        newNumber = (newNumber &lt;&lt; 1) | (number &amp; 1);
        number &gt;&gt;= 1;
    }
    return newNumber;
}




Hint: I have only considered the given range. I did not think about negative numbers.



You could try to avoid Scanner and use Integer.parseInt inside a try/catch. Who knows what they throw at you at the command line. The nextInt from Scanner does a Integer.parseInt, but it also tries to match tokens.