Base 7

Given an integer num, return a string with its base 7 representation. Negative numbers keep a leading minus sign.

30:00

Base 7
easy
Free written solution
Topics
Companies

Given an integer num, return a string with its base 7 representation. Negative numbers keep a leading minus sign.

Example 1:
Input: {"num":100}
Output: 202
Constraints:
  • −107≤num≤107-10^7 \leq \text{num} \leq 10^7

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"num":100}

Convert 100 to base 7. Dividing by 7 peels off the last base-7 digit as the remainder, the same way dividing by 10 peels off the last decimal digit.

Division ladder: n = 7 × q + r

n = 100

Base-7 answer, filled from the right

49
7
1

0 of 3 digits found

Variables
VariableValue
num100
n100
digits""
DepthFunction Call
Stack empty
0/10