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.

Showing 1-4 of 4 results.

A050249 Weakly prime numbers (changing any one decimal digit always produces a composite number). Also called digitally delicate primes.

Original entry on oeis.org

294001, 505447, 584141, 604171, 971767, 1062599, 1282529, 1524181, 2017963, 2474431, 2690201, 3085553, 3326489, 4393139, 5152507, 5564453, 5575259, 6173731, 6191371, 6236179, 6463267, 6712591, 7204777, 7469789, 7469797
Offset: 1

Views

Author

Keywords

Comments

Tao proved that this sequence is infinite. - T. D. Noe, Mar 01 2011
For k = 5, 6, 7, 8, 9, 10, the number of terms < 10^k in this sequence is 0, 5, 35, 334, 3167, 32323. - Jean-Marc Rebert, Nov 10 2015

References

  • Michael Filaseta and Jeremiah Southwick, Primes that become composite after changing an arbitrary digit, Math. Comp. (2021) Vol. 90, 979-993. doi:10.1090/mcom/3593

Crossrefs

Cf. A118118, A158124 (weakly primes), A158125 (weakly primes).
Cf. A137985 (analogous base-2 sequence), A186995 (weak primes in base n).

Programs

  • Magma
    IsA118118:=function(n); D:=Intseq(n); return forall{ : k in [1..#D], j in [0..9] | j eq D[k] or not IsPrime(Seqint(S)) where S:=Insert(D, k, k, [j]) }; end function; [ p: p in PrimesUpTo(8000000) | IsA118118(p) ]; // Klaus Brockhaus, Feb 28 2011
    
  • Mathematica
    fQ[n_] := Block[{d = IntegerDigits@ n, t = {}}, Do[AppendTo[t, FromDigits@ ReplacePart[d, i -> #] & /@ DeleteCases[Range[0, 9], x_ /; x == d[[i]]]], {i, Length@ d}]; ! AnyTrue[Flatten@ t, PrimeQ]] ; Select[Prime@ Range[10^5], fQ] (* Michael De Vlieger, Nov 10 2015, Version 10 *)
  • PARI
    isokp(n) = {v = digits(n); for (k=1, #v, w = v; for (j=0, 9, if (j != v[k], w[k] = j; ntest = subst(Pol(w), x, 10); if (isprime(ntest), return(0));););); return (1);}
    lista(nn) = {forprime(p=2, nn, if (isokp(p), print1(p, ", ")););} \\ Michel Marcus, Dec 15 2015
    
  • Python
    from sympy import isprime
    def h1(n): # hamming distance 1 neighbors of n
        s = str(n); d = "0123456789"; L = len(s)
        yield from (int(s[:i]+c+s[i+1:]) for c in d for i in range(L) if c!=s[i])
    def ok(n): return isprime(n) and all(not isprime(k) for k in h1(n) if k!=n)
    print([k for k in range(10**6) if ok(k)]) # Michael S. Branicky, Jun 19 2022

Extensions

Edited by Charles R Greathouse IV, Aug 02 2010

A158124 Weakly prime numbers (or isolated primes): changing any one decimal digit always produces a composite number, with restriction that first digit may not be changed to a 0.

Original entry on oeis.org

294001, 505447, 584141, 604171, 929573, 971767, 1062599, 1282529, 1524181, 2017963, 2474431, 2690201, 3070663, 3085553, 3326489, 4393139, 5152507, 5285767, 5564453, 5575259, 5974249, 6173731, 6191371, 6236179, 6463267, 6712591, 7204777, 7469789, 7469797, 7810223
Offset: 1

Views

Author

Eric W. Weisstein, Mar 13 2009

Keywords

Comments

The definition could be restated as "primes p with d digits such that there is no prime q with at most d digits at Hamming distance 1 from p (in base 10)". - N. J. A. Sloane, May 06 2019
For the following values of k, 5, 6, 7, 8, 9, 10, the number of terms < 10^k in this sequence is 0, 6, 43, 406, 3756, 37300. - Jean-Marc Rebert, Nov 10 2015

Crossrefs

Cf. A050249, A158125 (weakly primes), A186995, A192545.

Programs

  • Maple
    filter:= proc(n)
      local L,i,d,ds;
      if not isprime(n) then return false fi;
      L:= convert(n,base,10);
      for i from 1 to nops(L) do
        if i = nops(L) then ds:= {$1..9} minus {L[i]}
        elif i = 1 then ds:= {1,3,7,9} minus {L[i]}
        else ds:= {$0..9} minus {L[i]}
        fi;
        for d in ds do
          if isprime(n + (d - L[i])*10^(i-1)) then return false fi;
        od
      od;
      true
    end proc:
    select(filter, [seq(i,i=11..10^6,2)]); # Robert Israel, Dec 15 2015
  • Mathematica
    Select[Prime@ Range[10^5], Function[n, Function[w, Total@ Map[Boole@ PrimeQ@ # &, DeleteCases[#, n]] &@ Union@ Flatten@ Map[Function[d, FromDigits@ ReplacePart[w, d -> #] & /@ If[d == 1, #, Prepend[#, 0]] &@ Range@ 9], Range@ Length@ w] == 0]@ IntegerDigits@ n]] (* Michael De Vlieger, Dec 13 2016 *)
  • PARI
    isokp(n) = {v = digits(n); for (k=1, #v, w = v; if (k==1, idep = 1, idep=0); for (j=idep, 9, if (j != v[k], w[k] = j; ntest = subst(Pol(w), x, 10); if (isprime(ntest), return(0));););); return (1);}
    lista(nn) = {forprime(p=2, nn, if (isokp(p), print1(p, ", ")););} \\ Michel Marcus, Dec 15 2015
    
  • Python
    from sympy import isprime
    def h1(n): # hamming distance 1 neighbors of n, not starting with 0
        s = str(n); d = "0123456789"; L = len(s)
        yield from (int(s[:i]+c+s[i+1:]) for c in d for i in range(L) if c!=s[i] and not (i==0 and c=="0"))
    def ok(n): return isprime(n) and all(not isprime(k) for k in h1(n))
    print([k for k in range(10**6) if ok(k)]) # Michael S. Branicky, Jul 31 2022

Extensions

Edited by Charles R Greathouse IV, Aug 02 2010
Missing a(3385) inserted into b-file by Andrew Howroyd, Feb 23 2018

A192545 Numbers such that all numbers are composite when replacing exactly one digit with another, except the leading digit with zero.

Original entry on oeis.org

200, 202, 204, 205, 206, 208, 320, 322, 324, 325, 326, 328, 510, 512, 514, 515, 516, 518, 530, 532, 534, 535, 536, 538, 620, 622, 624, 625, 626, 628, 840, 842, 844, 845, 846, 848, 890, 892, 894, 895, 896, 898, 1070, 1072, 1074, 1075, 1076, 1078, 1130, 1132
Offset: 1

Views

Author

Reinhard Zumkeller, Jul 05 2011

Keywords

Comments

A048853(a(n)) = 0;
Intersection of this sequence and A000040 is A158124. - Evgeny Kapun, Dec 13 2016
If the last digit of an element is 0, 2, 4, 5, 6 or 8, then replacing it with 0, 2, 4, 5, 6 or 8 also yields an element. - David A. Corneth and corrected by Evgeny Kapun, Dec 13 2016

Crossrefs

Programs

  • Haskell
    import Data.List (elemIndices)
    a192545 n = a192545_list !! (n-1)
    a192545_list = map (+ 1) $ elemIndices 0 $ map a048853 [1..]
  • Mathematica
    Select[Range@ 1200, Function[w, Total@ Boole@ Flatten@ Map[Function[d, PrimeQ@ FromDigits@ ReplacePart[w, d -> #] & /@ If[d == 1, #, Prepend[#, 0]] &@ Range@ 9], Range@ Length@ w] == 0]@ IntegerDigits@ # &] (* Michael De Vlieger, Dec 13 2016 *)

A158641 Strong primes p: adding 2 to any one digit of p produces a prime number (no digits 8 & 9 in p).

Original entry on oeis.org

3, 5, 11, 17, 41, 107, 137, 347, 2111, 2657, 3527, 4421, 6761, 21011, 24371, 32057
Offset: 1

Views

Author

Zak Seidov, Mar 23 2009

Keywords

Comments

All terms are lesser of twin pairs.
The sequence is finite. In particular, there are no terms longer than 5 digits since 2*10^k for k=0,1,...,5 give all nonzero residues modulo 7, implying that adding 2 to some digit yields a multiple of 7. - Max Alekseyev, Apr 25 2010

Examples

			2111 is in this sequence because all 2111, 4111, 2311, 2131 and 2113 are prime numbers.
32057 is in this sequence because all 32057, 52057, 34057, 32257, 32077 and 32059 are prime numbers.
		

Crossrefs

Cf. A050249, A158124, A158125 Weakly prime numbers (changing any one digit always produces a composite number).

Programs

  • Maple
    Lton := proc(L) local i; add(op(i,L)*10^(i-1),i=1..nops(L)) ; end: isA158641 := proc(p) local pdgs,pplus,i ; if isprime(p) then pdgs := convert(p,base,10) ; if convert(pdgs,set) intersect {8,9} <> {} then false; else for i from 1 to nops(pdgs) do pplus := subsop(i=2+op(i,pdgs),pdgs) ; if not isprime(Lton(pplus)) then RETURN(false); fi; od: true; fi; else false; fi; end: for n from 1 do p := ithprime(n) ; if isA158641(p) then print(p) ; fi; od: # R. J. Mathar, Apr 16 2009
  • Mathematica
    spQ[p_]:=Max[IntegerDigits[p]]<8&&AllTrue[FromDigits/@Table[MapAt[ 2+#&,IntegerDigits[ p],n],{n,IntegerLength[p]}],PrimeQ]; Select[Prime[ Range[ 3500]],spQ] (* Harvey P. Dale, Nov 26 2022 *)
  • PARI
    test(p)=my(v=eval(Vec(Str(p)))); for(i=1,#v, if(v[i]>7,return(0))); for(i=0,#v-1, if(!isprime(p+2*10^i), return(0))); 1
    forprime(p=2,4e9, if(isprime(p+2) && test(p), print1(p","))) \\ Charles R Greathouse IV, Sep 09 2009
    
  • PARI
    has(n)=if(vecmax(Set(digits(n)))>7, return(0)); for(i=0,#digits(n)-1, if(!isprime(n+2*10^i), return(0))); 1
    select(has, primes(3438)) \\ Charles R Greathouse IV, Mar 11 2016

Extensions

Keywords full, fini from Max Alekseyev, Apr 25 2010
Showing 1-4 of 4 results.