fb pixel

Algorithms and Data Structures

  • Profound Academy

    • Status
      • 1
        Implementation
      • 2
        Bitwise operations
      • 3
        Prefix Sums
      • 4
        Sliding window / Two pointers
      • 5
        Modular Arithmetic
      • 6
        Number Theory
      • 7
        Binary Search
      • 8
        Basic Sorting
      • 9
        Greedy Algorithms

  • Hex (base-16) → Octal (base-8)

    Given a hexadecimal number (base-16), you are asked to calculate the equivalent octal (base-8) number.
    Decimal (base-10)
    Binary (base-2)
    Hex (base-16)
    Octal (base-8)
    0
    00000
    0
    0
    1
    00001
    1
    1
    2
    00010
    2
    2
    3
    00011
    3
    3
    4
    00100
    4
    4
    5
    00101
    5
    5
    6
    00110
    6
    6
    7
    00111
    7
    7
    8
    01000
    8
    10
    9
    01001
    9
    11
    10
    01010
    A
    12
    11
    01011
    B
    13
    12
    01100
    C
    14
    13
    01001
    D
    15
    14
    01010
    E
    16
    15
    01011
    F
    17
    16
    10000
    10
    20

    Input

    The input contains a single line representing the hex number n as a string (1 ≤ |n| ≤ 10000).

    Output

    The output should contain a single line representing the octal representation of n.

    Examples

    Input
    Output
    F
    17
    AF3
    5363

    Explanation

     
    To check your solution you need to sign in
    Sign in to continue