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.

A385280 a(n) is the number of n-digit primes of which all digits except one are the same.

This page as a plain text file.
%I A385280 #20 Jul 02 2025 18:08:56
%S A385280 4,20,46,43,40,53,35,49,40,38,44,52,35,45,49,42,38,57,27,45,38,47,37,
%T A385280 52,33,45,56,38,36,65,29,56,48,40,38,58,37,33,57,40,37,61,41,39,37,44,
%U A385280 36,55,47,43,47,43,35,62,43,46,29,35,37,56,39,41,46,48,39,74,45,34,34,35,34,67,39,45,43
%N A385280 a(n) is the number of n-digit primes of which all digits except one are the same.
%C A385280 a(n) is the number of n-digit primes obtained by changing one digit of an n-digit repdigit.
%H A385280 Robert Israel, <a href="/A385280/b385280.txt">Table of n, a(n) for n = 1..1000</a>
%e A385280 a(5) = 40 because there are 40 5-digit primes of which all digits but one are the same, namely 10111, 11113, 11117, 11119, 11131, 11161, 11171, 11311, 11411, 16111, 22229, 23333, 31333, 33331, 33343, 33353, 33533, 38333, 44449, 47777, 49999, 59999, 67777, 71777, 76777, 77377, 77477, 77747, 77773, 77797, 77977, 79777, 79999, 88883, 94999, 97777, 98999, 99929, 99989, 99991.
%p A385280 f:= proc(n)
%p A385280      local i,j,m, m2, t;
%p A385280      t:= 0;
%p A385280      for i from 1 to 9 do
%p A385280        for j in {$0..9} minus {i} do
%p A385280           if (n-1)*i + j mod 3 = 0 then next fi;
%p A385280           if j = 0 then m2:= n-2 else m2:= n-1 fi;
%p A385280           if not member(i,{1,3,7,9}) then m2:= 0 fi;
%p A385280           t:= t + nops(select( isprime,{seq((10^n-1)/9*i + 10^m*(j-i),m=0..m2)}))
%p A385280      od od;
%p A385280      t
%p A385280 end proc:
%p A385280 f(1):= 4: f(2):= 20:
%p A385280 map(f, [$1..100]);
%o A385280 (Python)
%o A385280 from gmpy2 import is_prime, digits
%o A385280 def a(n):
%o A385280     Rn = (10**n-1)//9
%o A385280     return len(set(t for d in range(1, 10) for i in range(n if d in {1, 3, 7, 9} else 1) for c in set(range(-d, 10-d))-{0} if len(digits(t:=d*Rn+c*10**i))==n and is_prime(t)))
%o A385280 print([a(n) for n in range(1, 76)]) # _Michael S. Branicky_, Jun 25 2025
%Y A385280 Cf. A004022, A010785, A084673, A241206.
%Y A385280 Essentially the same as A258915.
%K A385280 nonn,base
%O A385280 1,1
%A A385280 _Robert Israel_, Jun 24 2025