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.

A216167 Composite numbers which yield a prime whenever a 5 is inserted anywhere in them, excluding at the end.

This page as a plain text file.
%I A216167 #19 Oct 02 2022 17:06:41
%S A216167 9,21,57,63,69,77,87,93,153,231,381,407,413,417,501,531,581,651,669,
%T A216167 741,749,783,791,987,1241,1551,1797,1971,2189,2981,3381,3419,3591,
%U A216167 3951,4083,4503,4833,4949,4959,5049,5117,5201,5229,5243,5529,5547,5603,5691,5697
%N A216167 Composite numbers which yield a prime whenever a 5 is inserted anywhere in them, excluding at the end.
%H A216167 Michael S. Branicky, <a href="/A216167/b216167.txt">Table of n, a(n) for n = 1..1923</a> (terms 1..300 from Paolo P. Lava)
%e A216167 4083 is not prime but 40853, 40583, 45083 and 54083 are all primes.
%p A216167 with(numtheory);
%p A216167 A216167:=proc(q,x)
%p A216167 local a,b,c,i,n,ok;
%p A216167 for n from 1 to q do
%p A216167 if not isprime(n) then
%p A216167   a:=n; b:=0; while a>0 do b:=b+1; a:=trunc(a/10); od; a:=n; ok:=1;
%p A216167   for i from 1 to b do c:=a+9*10^i*trunc(a/10^i)+10^i*x;
%p A216167     if not isprime(c) then ok:=0; break; fi;
%p A216167   od;
%p A216167   if ok=1 then print(n); fi;
%p A216167 fi;
%p A216167 od; end:
%p A216167 A216167(1000,5);
%t A216167 Select[Range[6000],CompositeQ[#]&&AllTrue[FromDigits/@Table[Insert[IntegerDigits[#],5,p],{p,IntegerLength[#]}],PrimeQ]&] (* _Harvey P. Dale_, Oct 02 2022 *)
%o A216167 (Magma) [n: n in [1..6000] | not IsPrime(n) and forall{m: t in [1..#Intseq(n)] | IsPrime(m) where m is (Floor(n/10^t)*10+5)*10^t+n mod 10^t}]; // _Bruno Berselli_, Sep 03 2012
%o A216167 (Python)
%o A216167 from sympy import isprime
%o A216167 def ok(n):
%o A216167     if n < 2 or n%10 not in {1, 3, 7, 9} or isprime(n): return False
%o A216167     s = str(n)
%o A216167     return all(isprime(int(s[:i] + '5' + s[i:])) for i in range(len(s)))
%o A216167 print(list(filter(ok, range(5698)))) # _Michael S. Branicky_, Sep 21 2021
%Y A216167 Cf. A068673, A068674, A068677, A068679, A069246, A215417, A215419-A215421, A216165, A216166, A216168, A216169.
%Y A216167 Subsequence of A053795.
%K A216167 nonn,look,base
%O A216167 1,1
%A A216167 _Paolo P. Lava_, Sep 03 2012