We use the following observation: Any odd numbers x1,…,xk satisfy
x1x2+x2x3+⋯+xk−1xk+xkx1≡k(mod4).(∗)
Note that the sum in (∗) is cyclic, unlike the ones in the statement. To justify (∗) reduce the xi mod 4; then they become +1's or −1's as odd numbers are congruent to ±1 mod 4. Note that replacing an xi=−1 by xi=1 does not change the mod 4 remainder of S=∑j=1kxjxj+1. Indeed the new and the old value of S differ by 2(xi−1+xi+1) which is a multiple of 4 as xi−1,xi+1 are odd. So we may assume xi=1 for all i, then S=k and (∗) is obvious.
Let d1d2…d2013 satisfy the stated conditions. By (∗) we have ∑j=11810djdj+1≡1810(mod4) (here
d_{1810} + 1 = d_1), hence ∑j=11809djdj+1≡1(mod4) if and only if 1810−d1810d1≡1(mod4), i.e.
d1d1810≡1(mod4).
Similarly ∑j=18102012djdj+1≡1(mod4) if and only if (2013−1809)−d1810d2013≡1(mod4), i.e.
d1810d2013≡−1(mod4). We see that the conditions depend only on the three digits d1,d1810,d2013; the
remaining 2010 digits di can be chosen arbitrarily among 1,3,5,7,9.
There are 3 odd decimal digits ≡1(mod4), namely 1,5,9; there are 2 odd digits ≡−1(mod4),
namely 3,7. Let d1810∈{1,5,9}. Then d1d1810≡1(mod4) and d1810d2013≡−1(mod4) imply
d1∈{1,5,9},d2013∈{3,7}. So there are 3 choices for each of d1 and d1810, and 2 choices for d2013.
The choices are independent, which gives 3⋅3⋅2=18 admissible choices for the triple d1,d1810,d2013.
Because there are 5 choices for each of the remaining 2010 digits di (they can be arbitrary), we
obtain 18⋅52010 admissible numbers d1d2…d2013 with d1810∈{1,5,9}.
Likewise if d1810∈{3,7} then d1∈{3,7}, d2013∈{1,5,9}. Thus there are 2 choices for each of d1 and
d1810, and 3 choices for d2013, leading to 2⋅2⋅3=12 admissible choices for the triple d1,d1810,d2013.
Like in the previous case we obtain 12⋅52010 admissible numbers with d1810∈{3,7}.
In summary there are 18⋅52010+12⋅52010=6⋅52011 admissible numbers in all.