For example: 10 hex 16 hex turn, calculated as in Example
- 1958 turn hex
- 1958 % 16 == 6 1958 / 16 == 122
- 10 122% 16 == i.e. A 122/16 == 7
- 7 < 16
- 1958 hex for the 7A6
- Note: once as a dividend under the business
- The remainder is retained (the definition of a string, into every ADD). but. Hexadecimal, the conversion of more than 9 To character,
-
public static String decToHex(int n) {
String r = "";while (n > 16) { int yushu = n % 16; int shang = n / 16; if (yushu > 9) { char c = (char)((yushu - 10) + 'A'); r += c; } else { r += yushu; } n = shang; } if (n > 9) { char c = (char)((n - 10) + 'A'); r += c; } else { r += n; } return reverse(r);
}
Factorial / recursively repeated calls using
public static Long factorial (n-int) {
IF (n-n-== == 0 ||. 1) {
return. 1;
} `` the else {
return * n-factorial (n--. 1);
}
}
// iterative way factorial retains the last calculated result, additional
public static Long factorial2 The (n-int) {
int. 1 = R & lt;
for (int I =. 1; I <= n-; I ++) {
// R & lt = R & lt I;
R & lt I =;
}
return r;
}