Question 7 Consider the following functions for reversing a number's digits in base-10, and calculating the result in given base (simultaneously).For example, convertRadix(23, 16) will return 50, since 23 reversed is 32, but represents 50 in base-16 (tex). Written in common notation, tex. Complete the conversionStep function to achive this goa . public static int conversionStep(int state, int radix) { int result = { /* 1 */, state /* 2 */ + state /* 3 */ }; return result; } public static int convertRadix(int n, int radix) { int state = { n, 0 }; while (state != 0) state = conversionStep(state, radix); return /* 4 */; }
|