A166580 Prime numbers containing the string 222.
2221, 12227, 22229, 22247, 22259, 22271, 22273, 22277, 22279, 22283, 22291, 42221, 42223, 42227, 52223, 72221, 72223, 72227, 72229, 82223, 92221, 92227, 102229, 112223, 122201, 122203, 122207, 122209, 122219, 122231, 122251, 122263, 122267, 122273, 122279, 122299, 132229, 142223
Offset: 1
Links
- Vincenzo Librandi, Table of n, a(n) for n = 1..1000
Programs
-
Magma
res := []; for n in [1..15000] do p := NthPrime(n); digits := IntegerToSequence(p); for i in [1..#digits - 2] do if digits[i..i+2] eq [2,2,2] then Append(~res, p); break; end if; end for; end for; res; // Vincenzo Librandi, Jul 16 2025
-
Mathematica
p222Q[n_] := Module[{idn = IntegerDigits[n]}, MemberQ[Partition[idn, 3, 1], {2, 2, 2}]]; Select[Prime[Range[15000]], p222Q] (* Vincenzo Librandi Sep 14 2012 *) Select[Prime[Range[12000]],SequenceCount[IntegerDigits[#],{2,2,2}]>0&] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Nov 08 2017 *)
-
PARI
contains(n,k)=my(N=digits(n),K=digits(k)); for(i=0,#N-#K, for(j=1,#K,if(N[i+j]!=K[j],next(2))); return(1)); 0 is(n)=isprime(n) && contains(n,222) \\ Charles R Greathouse IV, Jun 20 2014
Formula
a(n) ~ n log n. - Charles R Greathouse IV, Jun 20 2014