Multiples of seven P91736


Statement
 

pdf   zip

For every natural nn, let X(n)X(n) be the smallest natural mm such that mm ends with nn and mm is a multiple of 7. For instance, X(1)=21X(1) = 21, X(2)=42X(2) = 42, X(3)=63X(3) = 63, …, X(7)=7X(7) = 7, X(8)=28X(8) = 28, X(9)=49X(9) = 49, X(10)=210X(10) = 210, X(11)=511X(11) = 511, … Let SS be the infinite concatenation of X(i)X(i) for every i1i \ge 1, that is, S=21426314355672849210511...S = 21426314355672849210511.... Which is the ii-th digit of SS?

Input

Input consists of several cases, each with a natural ii between 1 and 101510^{15}.

Output

For every ii, print the ii-th digit of SS (starting at one).

Public test cases
  • Input

    1
    2
    3
    4
    13
    14
    15
    18
    19
    20
    1000000000000
    1000000000000000
    

    Output

    2
    1
    4
    2
    7
    2
    8
    2
    1
    0
    4
    5
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++