OFFSET
1,1
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..47 (terms 1..27 from David A. Corneth)
David A. Corneth, PARI program
FORMULA
a(2*n-1) = 9*10^(n-1) with a(1) = 10.
a(n) = A063945(n) for n odd.
EXAMPLE
From David A. Corneth, Dec 03 2024: (Start)
a(3) = 900 as every positive integer between (inclusive) 100 and 999 contains its median. The median is the middle digit after sorting which is in the digits.
a(4) = 1665. For example 2558 has digits sorted and the median, 5 is in the digits of 2558 and any permutation of digits of 2558. There are 12 such permutations so 2558 contributes 12 towards the total of a(4).
0258 has digits sorted (but a leading 0) and has 24 permutations. To account for the leading 0 we remove it and deduce the number of permutations from what is left, namely 258. That has 6 permutations. So in total 0258 adds 24 - 6 = 18 towards the total of a(4). (End)
MATHEMATICA
a[n_]:=If[OddQ[n], KroneckerDelta[n, 1]+9*10^(n-1), Module[{c=0}, For[k=10^(n-1), k<=10^n-1, k++, If[MemberQ[digits=IntegerDigits[k], Median[digits]], c++]]; c]]; Array[a, 7]
PROG
(PARI) \\ See Corneth link
(Python)
from math import prod, factorial
from itertools import combinations_with_replacement
from collections import Counter
def A378564(n):
if n==1: return 10
if n&1: return 9*10**(n-1)
c, f = 0, factorial(n-1)
for p in combinations_with_replacement(range(10), n):
if max(p):
a = sorted(p)
b = a[len(a)-1>>1]+a[len(a)>>1]
if b&1^1 and b>>1 in p:
v = Counter(d for d in p if d).values()
s = sum(v)
q = prod((factorial(i) for i in v))*factorial(n-s)
c += sum(f*i//q for i in v)
return c # Chai Wah Wu, Dec 14 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Stefano Spezia, Dec 01 2024
EXTENSIONS
More terms from David A. Corneth, Dec 03 2024
STATUS
approved