login
a(n) = most common final digit for a prime < 10^n, or 0 if there is a tie.
2

%I #31 Sep 27 2014 04:59:52

%S 0,3,7,3,7,3,3,7,3,3,7,7,3,3

%N a(n) = most common final digit for a prime < 10^n, or 0 if there is a tie.

%H <a href="/index/Fi#final">Index entries for sequences related to final digits of numbers</a>

%e For all 25 primes < 100 (10^2), we see that the last digit that appears the most is 3. Thus a(2) = 3.

%o (Python)

%o import sympy

%o from sympy import isprime

%o def prend(d,n):

%o ..lst = []

%o ..for k in range(10**n):

%o ....if isprime(k):

%o ......lst.append((k%10**d))

%o ..new = 0

%o ..newlst = []

%o ..for i in range(10**(d-1),10**d):

%o ....new = lst.count(i)

%o ....newlst.append(new)

%o ..newlst1 = newlst.copy()

%o ..a = max(newlst1)

%o ..newlst1[newlst1.index(a)] = 0

%o ..b = max(newlst1)

%o ..if a == b:

%o ....return 0

%o ..else:

%o ....return newlst.index(max(a,b)) + 10**(d-1)

%o n = 2

%o while n < 10:

%o ..print(prend(1,n),end=', ')

%o ..n += 1

%Y Cf. A007652, A095178, A244192.

%K nonn,base,hard,more

%O 1,2

%A _Derek Orr_, Jun 22 2014

%E a(9)-a(14) from _Hiroaki Yamanouchi_, Sep 27 2014