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.

A377571 a(n) is a n-digit number; for k = 1..n, its k-th digit is the most frequent k-th digit among n-digit prime numbers; in case of a tie, preference is given to the least digit.

Original entry on oeis.org

2, 13, 157, 1223, 12127, 104993, 1000597, 10289067, 100080553, 1000447633, 10015225131
Offset: 1

Views

Author

Rémy Sigrist, Nov 01 2024

Keywords

Comments

Although each digit taken independently is the most likely to be in that position for a prime number, overall, a term is not necessarily a prime number; for example, a(5) = 67 * 181 is composite.
For n>1, a(n)'s last digit is either 1, 3, 7 or 9. The prime number theorem says that the number of primes <= n is not linear with n, but grows sparser at a rate of n/log(n) so we expect the first digit of a(n) to be equal to 1 and the k-th digit of a(n) to be 0 for k>1 fixed and as n -> oo. - Chai Wah Wu, Nov 06 2024

Examples

			For n = 4: the frequency of digits among 4-digit prime numbers, and the corresponding most frequent digits, are:
  Digit    0     1     2     3    4    5    6    7    8    9  Most frequent
  -----  ---  ----  ----  ----  ---  ---  ---  ---  ---  ---  -------------
  1st      0   135*  127   120  119  114  117  107  110  112              1
  2nd    112    95   116*  104  104  107  115  104  106   98              2
  3rd    105   107   116*  110  103  106  104  101  105  104              2
  4th      0   266     0   268*   0    0    0  262    0  265              3
- so a(4) = 1223.
		

Crossrefs

Programs

  • PARI
    a(n, base = 10) = { my (f = vector(n, k, vector(base))); forprime (p = base^(n-1), base^n-1, my (d = digits(p, base)); for (k = 1, n, f[k][1+d[k]]++;);); my (b = vector(n), i); for (k = 1, n, vecmax(f[k], &i); b[k] = i-1;); fromdigits(b, base); }
    
  • Python
    from sympy import primerange
    def A377571(n):
        c = [[0]*10 for i in range(n)]
        for p in primerange(10**(n-1),10**n):
            for i, j in enumerate(str(p)):
                c[i][int(j)]+=1
        return int(''.join(str(c[i].index(max(c[i]))) for i in range(n))) # Chai Wah Wu, Nov 06 2024