Decimal to Octal
Given a non-negative decimal integer n, return its octal representation as a string. Use only digits 0 through 7. Do not include a leading zero or a base…
Given a non-negative decimal integer `n`, return its octal representation as a string. Use only digits `0` through `7`. Do not include a leading zero or a base prefix; represent zero as `"0"`.
- `0 <= n <= 10^9` - Return one exact uppercase-free string with no prefix or leading zeroes.
Example 1: input n = 83; output "123". 83 = 1×64 + 2×8 + 3.
Example 2: input n = 64; output "100". 64 is 8 squared, so it is one followed by two octal zeroes.
Category: Math & Numbers. Topic: math. Difficulty: Easy. Patterns: math.