login
a(n) is the unique n-digit odd number (including leading zero(s)) with alternating even and odd digits and divisible by 5^n.
1

%I #23 Feb 24 2021 08:17:45

%S 5,25,125,8125,78125,78125,5078125,5078125,705078125,2705078125,

%T 72705078125,272705078125,3272705078125,23272705078125,

%U 323272705078125,4323272705078125,74323272705078125,474323272705078125,1474323272705078125,61474323272705078125,561474323272705078125

%N a(n) is the unique n-digit odd number (including leading zero(s)) with alternating even and odd digits and divisible by 5^n.

%C 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.

%C 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

%F a(n) = Sum_{i=0..n-1} A321289(i)*10^i.

%e a(2) is the unique number in {5, 25, 45, 65, 85} that is divisible by 25, which is 25.

%e a(3) is the unique number in {125, 325, 525, 725, 925} that is divisible by 125, which is 125.

%e a(4) is the unique number in {125, 2125, 4125, 6125, 8125} that is divisible by 625, which is 8125.

%e a(5) is the unique number in {18125, 38125, 58125, 78125, 98125} that is divisible by 3125, which is 78125.

%t 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 *)

%o (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}

%o a(n) = seq(n)[n] \\ Program provided by _Andrew Howroyd_

%Y Cf. A321289.

%K nonn,base

%O 1,1

%A _Jianing Song_, Nov 02 2018