Given a positive integer (including 0), convert it to its hexadecimal representation.
Input:
n(integer)
Output:
- A string representing the hexadecimal value of
n
Examples:
0 => "0"
1 => "1"
2 => "2"
3 => "3"
9 => "9"
10 => "a"
11 => "b"
15 => "f"
16 => "10"
30 => "1e"
31 => "1f"
32 => "20"
255 => "ff"
256 => "100"
This problem asks you to convert a decimal integer into its hexadecimal string representation. The standard approach is to repeatedly divide by 16, collect each remainder as a hex digit, and then reverse the collected digits at the end. Values 10 through 15 must be mapped to 'a' through 'f', and the edge case 0 should return "0" directly.