申論題內容
五、輸入 34 於下列 getBinary 遞迴程式,請問回傳值為何?(20 分)
/** getBinary returns a String representation of the binary
* equivalent of a specified integer n.
* The worstTime(n) is O(log n).*
* @param n – an int in decimal notation.
* @return the binary equivalent of n, as a String
* @throws IllegalArgumentException, if n is less than 0
*/
public static String getBinary (int n) {
if (n < 0) throw new IllegalArgumentException( );
if (n <= 1) return Integer.toString (n);
return getBinary (n / 2) + Integer.toString (n % 2)
} // getBinary