#P0024. 7进制

7进制

1. Description

In math class we usually use decimal system, which means the number a on i-th position represents

a×10i1a\times 10^{i-1}

For example, the number 2 in 23 represents

2×1021=202\times 10^{2-1} = 20

Similarly, in septenary (Base-7) system, the number a on i-th position represents

a×7i1a\times 7^{i-1}

Only 0~6 are allowed on digit. Once the number reaches 7, it carries to next position. To convert a septenary number to a decimal one, we can make a calculation

$$(236)_7 = 2 * 7^2 + 3 * 7^1 + 6 * 7^0 = (125)_{10} $$

In this question, we'd like to code a function base7(), which takes a decimal number as input and convert it to a septenary representation.

2. Input & Output

Input:

  • A decimal integer
  • Use input() as input. Notice that the value you get from input() is a string

Output:

  • A septenary integer
  • Use print() for your output

Example

# Input: 
40
# Output: 
55
# Input: 
-7
# Output: 
-10