cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-6 of 6 results.

A378564 a(n) is the number of n-digit nonnegative integers with the median of the digits equal to one of the digits.

Original entry on oeis.org

10, 9, 900, 1665, 90000, 232710, 9000000, 29055165, 900000000, 3413319138, 90000000000, 386095933170, 9000000000000, 42568084276236, 900000000000000, 4607838122919165, 90000000000000000, 491998811785538730, 9000000000000000000, 51983526276872387430, 900000000000000000000, 5447302810160797285236
Offset: 1

Views

Author

Stefano Spezia, Dec 01 2024

Keywords

Examples

			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)
		

Crossrefs

Programs

  • 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]
  • 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

Formula

a(2*n-1) = 9*10^(n-1) with a(1) = 10.
a(n) = A063945(n) for n odd.

Extensions

More terms from David A. Corneth, Dec 03 2024

A378835 Numbers with the median of the digits equal to the digital root.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 99, 109, 118, 128, 138, 148, 158, 168, 178, 181, 182, 183, 184, 185, 186, 187, 188, 190, 209, 218, 227, 237, 247, 257, 267, 272, 273, 274, 275, 276, 277, 281, 290, 309, 318, 327, 336, 346, 356, 363, 364, 365, 366, 372, 381, 390, 409, 418, 427, 436, 445
Offset: 1

Views

Author

Stefano Spezia, Dec 09 2024

Keywords

Examples

			10 is not in the list because the median of its digits is not integer.
11 is not in the list because the median of its digits is 1 which is not equal to 2, the digital root of 11.
109 is in the list because the median of its digits is 1 which is equal to the digital root of 109.
		

Crossrefs

Programs

  • Mathematica
    A010888[n_]:=If[n==0,0,n - 9*Floor[(n-1)/9]]; Select[Range[0,450], Median[IntegerDigits[#]]==A010888[#] &]

A378836 a(n) is the number of n-digit nonnegative integers with the median of the digits equal to the digital root.

Original entry on oeis.org

10, 1, 131, 474, 10233, 50844, 1001250, 5225775, 99980565, 536333508, 9998984322, 55188464010, 999994914558, 5683515922236, 100001648752524, 585428890525092, 10000105972653645, 60302140270087340, 1000004027662440330, 6207976859006478708, 100000111315410065850
Offset: 1

Views

Author

Stefano Spezia, Dec 09 2024

Keywords

Crossrefs

Programs

  • Mathematica
    A010888[n_]:=If[n==0,0,n - 9*Floor[(n-1)/9]]; a[n_]:=If[n==1,10,Module[{c=0}, For[k=10^(n-1), k<=10^n-1, k++, If[Median[IntegerDigits[k]]==A010888[k], c++]]; c]]; Array[a, 6]
  • Python
    from math import prod, factorial
    from collections import Counter
    from sympy.utilities.iterables import partitions
    def A378836(n):
        if n==1: return 10
        c, f = 0, factorial(n-1)
        for i in range(1,9*n+1):
            for s,p in partitions(i,m=n,k=9,size=True):
                a = sorted(list(Counter(p).elements())+[0]*(n-s))
                b = a[len(a)-1>>1]+a[len(a)>>1]
                if b&1^1 and b>>1 == 1+(i-1)%9:
                    v = list(p.values())
                    p = prod((factorial(i) for i in v))*factorial(n-s)
                    c += sum(f*i//p for i in v)
        return c # Chai Wah Wu, Dec 12 2024

Extensions

a(11)-a(21) from Chai Wah Wu, Dec 12 2024

A378837 Numbers with the arithmetic mean of the digits equal to the digital root.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 99, 999, 1029, 1038, 1047, 1056, 1065, 1074, 1083, 1092, 1119, 1128, 1137, 1146, 1155, 1164, 1173, 1182, 1191, 1209, 1218, 1227, 1236, 1245, 1254, 1263, 1272, 1281, 1290, 1308, 1317, 1326, 1335, 1344, 1353, 1362, 1371, 1380, 1407, 1416, 1425, 1434, 1443
Offset: 1

Views

Author

Stefano Spezia, Dec 09 2024

Keywords

Examples

			10 is not in the list because the mean of its digits is not integer.
11 is not in the list because the mean of its digits is 1 which is not equal to 2, the digital root of 11.
1029 is in the list because the mean of its digits is 3 which is equal to the digital root of 1029.
		

Crossrefs

Programs

  • Mathematica
    A010888[n_]:=If[n==0,0,n - 9*Floor[(n-1)/9]]; Select[Range[0,1500], Mean[IntegerDigits[#]]==A010888[#] &]

A378838 a(n) is the number of n-digit nonnegative integers with the mean of the digits equal to the digital root.

Original entry on oeis.org

10, 1, 1, 748, 1, 1, 373327, 1, 1, 900000000, 1, 1, 118641180477, 1, 1, 70265700376176, 1, 1, 473609016175792282, 1, 1, 25843609164809475416, 1, 1, 15917111940073972644247, 1, 1, 319908753084273214311674685, 1, 1, 6159986083122001233681300544, 1, 1, 3860982462614939076156553701616, 1, 1
Offset: 1

Views

Author

Stefano Spezia, Dec 09 2024

Keywords

Crossrefs

Programs

  • Mathematica
    A010888[n_]:=If[n==0,0,n - 9*Floor[(n-1)/9]]; a[n_]:=If[n==1,10,Module[{c=0}, For[k=10^(n-1), k<=10^n-1, k++, If[Mean[IntegerDigits[k]]==A010888[k], c++]]; c]]; Array[a, 6]
  • Python
    from math import prod, factorial
    from sympy.utilities.iterables import partitions
    def A378838(n):
        if n==1: return 10
        if n%3!=1: return 1
        k, c, f = n%9, 0, factorial(n-1)
        a = 3*n if k==4 or k==7 else n
        for i in range(a,9*n+1,a):
            for s,p in partitions(i,m=n,k=9,size=True):
                v = list(p.values())
                p = prod((factorial(i) for i in v))*factorial(n-s)
                c += sum(f*i//p for i in v)
        return c # Chai Wah Wu, Dec 12 2024

Formula

Conjecture: a(A007494(n)) = 1.
From Chai Wah Wu, Dec 12 2024: (Start)
The above conjecture is true, i.e. if n == 0 or 2 mod 3, then a(n) = 1.
Proof: if m is a n-digit integer with mean of digits equal to its digital root k, then sum of digits of m is k*n.
Then m mod 9 = k*n mod 9. Since the digital root is k = 1 + (m-1) mod 9, this means that k = 1 + (k*n-1) mod 9. As 1<=k<=9, for n == 2, 3, 5, 6, 8, 9 mod 9 the only k that satisfies this equation is k=9. Then the only corresponding m whose digit sum is 9*n is 10^n-1. Thus a(n) = 1.
Other results:
Theorem 1: If n == 4 or 7 mod 9, then a(n) is the number of n-digit nonnegative integers with digit sum a multiple of 3*n.
Proof: Follows from the fact that the only k that satisfies k = 1 + (k*n-1) mod 9 is k = 3, 6, or 9.
Theorem 2: If n>1 and n == 1 mod 9, then a(n) is the number of n-digit nonnegative integers with digit sum a multiple of n.
Proof: Since n>1, the digital root of an n-digit integer is > 0. The result then follows from the fact that k = 1 + (k*n-1) mod 9 is satisfied for all 1<=k<=9.
(End)

Extensions

a(11)-a(36) from Chai Wah Wu, Dec 12 2024

A379180 Nonnegative integers with mode and mean of the digits equal.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 111, 222, 333, 444, 555, 666, 777, 888, 999, 1012, 1021, 1102, 1111, 1120, 1201, 1210, 1223, 1232, 1322, 1335, 1353, 1447, 1474, 1533, 1559, 1595, 1744, 1955, 2011, 2024, 2042, 2101, 2110, 2123, 2132
Offset: 1

Views

Author

Stefano Spezia, Dec 17 2024

Keywords

Examples

			1021 is a term since the mode and the mean of the digits are equal to 1.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[0,2200], Commonest[IntegerDigits[#]] == {Mean[IntegerDigits[#]]} &]
Showing 1-6 of 6 results.