OFFSET
1,1
COMMENTS
For n > 1, if n is even, then a(n) is the unique number in {a(n-1), a(n-1) + 2*10^(n-1), a(n-1) + 4*10^(n-1), a(n-1) + 6*10^(n-1), a(n-1) + 8*10^(n-1)} that divides 5^n; if n is odd, then a(n) is the unique number in {a(n-1) + 10^(n-1), a(n-1) + 3*10^(n-1), a(n-1) + 5*10^(n-1), a(n-1) + 7*10^(n-1), a(n-1) + 9*10^(n-1)} that divides 5^n.
The unique n-digit even number (including leading zero(s)) with alternating even and odd digits and divisible by 5^n is 0 if n = 1 and 10*a(n-1) if n > 1. - Jianing Song, Feb 24 2021
FORMULA
a(n) = Sum_{i=0..n-1} A321289(i)*10^i.
EXAMPLE
a(2) is the unique number in {5, 25, 45, 65, 85} that is divisible by 25, which is 25.
a(3) is the unique number in {125, 325, 525, 725, 925} that is divisible by 125, which is 125.
a(4) is the unique number in {125, 2125, 4125, 6125, 8125} that is divisible by 625, which is 8125.
a(5) is the unique number in {18125, 38125, 58125, 78125, 98125} that is divisible by 3125, which is 78125.
MATHEMATICA
n = 21; a[1] = 5; For[i=2, i <= n, i++, For[j=0, j <= 4, j++, t = a[i-1] + (2j + Mod[i, 2]) 10^(i-1); If[Mod[t, 5^i] == 0, a[i] = t; Break[]]]]; Array[a, n] (* Jean-François Alcover, Nov 23 2018, from PARI *)
PROG
(PARI) seq(n)={my(v=vector(n)); v[1]=5; for(i=2, n, for(j=0, 4, my(t=v[i-1] + (2*j + i%2)*10^(i-1)); if(t%(5^i)==0, v[i]=t; break))); v}
a(n) = seq(n)[n] \\ Program provided by Andrew Howroyd
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Jianing Song, Nov 02 2018
STATUS
approved