Number to Hexadecimal
STRING
MATH
Problem
Given a non-negative integer n
, convert it to a hexadecimal string. The returned hexadecimal string must not have leading zeroes, except for the number zero itself.
Examples
toHex(10) // returns "a" // 10 in decimal equals "a" in hexadecimal. toHex(16) // returns "10" // 16 in decimal is "10" in hexadecimal. toHex(255) // returns "ff" // 255 in decimal is "ff" in hexadecimal.
Loading...