OFFSET
1,1
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
EXAMPLE
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.
PROG
(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
CROSSREFS
KEYWORD
nonn,base,more
AUTHOR
Rémy Sigrist, Nov 01 2024
STATUS
approved