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.

A089771 Largest n-digit prime containing no prime substrings, or 0 if no such prime exists.

This page as a plain text file.
%I A089771 #14 Aug 30 2024 15:13:12
%S A089771 7,89,991,9949,99469,996649,9999481,99990091,999996901,9999988049,
%T A089771 99999981469,999999946849,9999999946009,99999999904081,
%U A089771 999999999946069,9999999999944869,99999999999884081,999999999999984469,9999999999999968869,99999999999999900049,999999999999999944009,9999999999999999999869
%N A089771 Largest n-digit prime containing no prime substrings, or 0 if no such prime exists.
%C A089771 Conjecture: No term is zero.
%H A089771 Robert Israel, <a href="/A089771/b089771.txt">Table of n, a(n) for n = 1..234</a>
%p A089771 cbd:= proc(n)
%p A089771   local x,L,i,flag;
%p A089771   L:= convert(n,base,10);
%p A089771   x:= n;
%p A089771   for i from nops(L) to 1 by -1 do
%p A089771     if member(L[i],{2,3,5,7}) then
%p A089771       flag:= true;
%p A089771       if L[i] = 3 then x:= x - 10^(i-1)- (x mod 10^(i-1)) -1 else x:= x - (x mod 10^(i-1)) - 1 fi;
%p A089771       return x
%p A089771     fi;
%p A089771   od;
%p A089771  x
%p A089771 end proc:
%p A089771 nps:= proc(n) option remember;
%p A089771   if n <= 10 then not isprime(n)
%p A089771   else not isprime(n) and nps(floor(n/10)) and nps(n mod 10^ilog10(n))
%p A089771   fi
%p A089771 end proc:
%p A089771 npps:= proc(n) local L,i,t;
%p A089771   if n <= 10 then true
%p A089771   else
%p A089771     if n::odd then return nps(floor(n/10)) and nps(n mod 10^ilog10(n)) fi;
%p A089771     for i from 1 do
%p A089771       t:= floor(n/10^i);
%p A089771       if t::odd then return nps(t) and nps(t mod 10^ilog10(t))
%p A089771       elif t = 0 then return true
%p A089771   fi od fi
%p A089771 end proc:
%p A089771 g:= proc(n) local p,i,x;
%p A089771   p:= 10^n;
%p A089771   do
%p A089771     p:= prevprime(p);
%p A089771     x:= cbd(p);
%p A089771     while x <> p do
%p A089771       p:= prevprime(x+1);
%p A089771       x:= cbd(p)
%p A089771     od;
%p A089771     if npps(p) then return p fi
%p A089771   od
%p A089771 end proc:
%p A089771 g(1):= 7:
%p A089771 map(g, [$1..30]); # _Robert Israel_, Aug 30 2024
%o A089771 (Python)
%o A089771 from sympy import isprime
%o A089771 from itertools import product
%o A089771 def c(s): return not any(isprime(int(s[i:j])) for i in range(len(s)-1, -1, -1) for j in range(len(s), i, -1) if (i, j) != (0, len(s)))
%o A089771 def a(n):
%o A089771     if n == 1: return 7
%o A089771     return next(t for p in product("986410", repeat=n-1) for last in "91" if isprime(t:=int(s:="".join(p)+last)) and c(s))
%o A089771 print([a(n) for n in range(1, 23)]) # _Michael S. Branicky_, Aug 30 2024
%Y A089771 Cf. A089768, A033274, A089770.
%K A089771 base,nonn
%O A089771 1,1
%A A089771 _Amarnath Murthy_, Nov 23 2003
%E A089771 More terms from _David Wasserman_, Oct 12 2005
%E A089771 More terms from _Robert Israel_, Aug 30 2024