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-8 of 8 results.

A158125 Weakly prime numbers in the sense of A158124 but not A050249.

Original entry on oeis.org

929573, 3070663, 5285767, 5974249, 7810223, 9262697, 9663683, 9700429, 10532453, 12968519, 19106729, 19158221, 19579907, 21825337, 23196157, 24328567, 29617897, 31181461, 31746383, 31839427, 36438379, 36745811, 37763641, 38585039, 38774851, 38888137, 39600559, 45412331, 45743483, 47500217, 47632271, 54127231, 56242891, 59816347
Offset: 1

Views

Author

Eric W. Weisstein, Mar 13 2009

Keywords

Comments

A158124: initial digit may not be changed to a zero (and hence give a number with fewer digits).
A050249: initial digit may be changed to a zero.
For the following values 5, 6, 7, 8, 9, 10 of k, the number of terms < 10^k in this sequence is 0, 1, 8, 72, 589, 4977. - Jean-Marc Rebert, Nov 10 2015
Intersection of A227916 and A158124. So primes p that give another prime when the first digit is removed, but give a composite number when any one digit is modified in a way that does not change the digit count. - Jeppe Stig Nielsen, Jan 16 2022

Crossrefs

Programs

  • PARI
    forprime(p=2,10^10,d=digits(p);!isprime(fromdigits(d[2..#d]))&&next();for(k=1,#d,for(j=(k==1),9,d[k]==j&&next();e=d;e[k]=j;isprime(fromdigits(e))&&next(3)));print1(p,", ")) \\ Jeppe Stig Nielsen, Jan 16 2022

A039818 Erroneous version of A158124.

Original entry on oeis.org

4409, 67307, 86573, 111857, 198349, 259507
Offset: 0

Views

Author

Keywords

A048853 Number of primes (different from n) that can be produced by altering one digit of decimal expansion of n (without changing the number of digits).

Original entry on oeis.org

4, 3, 3, 4, 3, 4, 3, 4, 4, 4, 7, 4, 8, 4, 4, 4, 7, 4, 7, 2, 7, 2, 6, 2, 2, 2, 7, 2, 5, 2, 5, 2, 8, 2, 2, 2, 5, 2, 7, 3, 6, 3, 7, 3, 3, 3, 6, 3, 8, 2, 7, 2, 6, 2, 2, 2, 7, 2, 5, 2, 5, 2, 8, 2, 2, 2, 5, 2, 7, 3, 6, 3, 7, 3, 3, 3, 8, 3, 6, 2, 7, 2, 6, 2, 2, 2, 7, 2, 5, 1, 6, 1, 7, 1, 1, 1, 4, 1, 6, 4, 10, 4, 8, 4, 4
Offset: 1

Views

Author

Keywords

Comments

a(A192545(n)) = 0. - Reinhard Zumkeller, Jul 05 2011

Examples

			Altering the number 13 gives eight primes: 11, 17, 19, 23, 43, 53, 73, 83, so a(13)=8.
		

Crossrefs

Programs

  • Haskell
    import Data.List (inits, tails, nub)
    a048853 n = (sum $ map (a010051 . read) $ tail $ nub $ concat $ zipWith
      (\its tls -> map ((\xs ys d -> xs ++ (d:ys)) its tls) "0123456789")
        (map init $ tail $ inits $ show n) (tail $ tails $ show n)) - a010051 n
    -- Reinhard Zumkeller, Jul 05 2011
    
  • Maple
    A048853 := proc(n::integer) local resul,ddigs,d,c,tmp ; resul := 0 ; ddigs := convert(n,base,10) ; for d from 1 to nops(ddigs) do for c from 0 to 9 do if c = 0 and d = nops(ddigs) then continue ; else if c <> op(d,ddigs) then tmp := [op(1..d-1,ddigs),c,op(d+1..nops(ddigs),ddigs)] ; tst := sum(op(i,tmp)*10^(i-1),i=1..nops(tmp)) ; if isprime(tst) then resul := resul+1 ; fi ; fi ; fi ; od : od ; RETURN(resul) ; end: for n from 1 to 90 do printf("%d,",A048853(n)) ; od ; # R. J. Mathar, Apr 25 2006
  • Mathematica
    a[n_] := Module[{idn = IntegerDigits[n], id, np = 0}, Do[id = idn; If[ id[[j]] != k, id[[j]] = k; If[ id[[1]] != 0 && PrimeQ[ FromDigits[id]], np = np + 1]], {j, 1, Length[idn]}, {k, 0, 9}]; np]; Table[a[n], {n, 1, 105}] (* Jean-François Alcover, Dec 01 2011 *)
  • 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 a(n): return sum(1 for k in h1(n) if isprime(k))
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Jul 31 2022

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

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 *)

A253269 Weakly Twin Primes in base 10: Can only reach one other prime by single-decimal-digit changes.

Original entry on oeis.org

89391959, 89591959, 519512471, 519512473, 531324041, 561324041, 699023791, 699023891, 874481011, 874487011, 1862537503, 2232483271, 2232483871, 2608559351, 3127181789, 3157181789, 3928401949, 3928401989, 4070171669, 4070171969, 5225628323, 5309756339, 5525628323
Offset: 1

Views

Author

Michael Kleber, May 01 2015

Keywords

Comments

Each pair of twins here form a size-two connected component in the graph considered in A158576.
A naive heuristic argument based on the density of primes claims that this sequence should be infinite, and in fact that a positive proportion of all primes should have this property. A prime p has 9*log_10(p) neighbors, each prime with "probability" 1/log(p), and with all the other 2*9*log_10(p) neighbors being composite with "probability" (1-1/log(p))^(2*9*log_10(p)). For a large prime p, this goes to the limit 9/(exp(18/log(10))*log(10)), or about 0.16%. The fact that base-10 primes need to end with digit 1/3/7/9 will change the value of this probability, but won't change the fact that it is nonzero.
This is analogous to a theorem about weakly prime numbers; see the Terence Tao paper referenced in A050249.

Crossrefs

Programs

  • Mathematica
    NeighborsAndSelf[n_] := Flatten[MapIndexed[Table[ n + (i - #)*10^(#2[[1]] - 1), {i, 0, 9}] &, Reverse[IntegerDigits[n, 10]]]]
    PrimeNeighbors[n_] := Complement[Select[NeighborsAndSelf[n],PrimeQ],{n}]
    WeaklyTwinPrime[p_] := (Length[#] == 1 && PrimeNeighbors[#[[1]]] == {p}) &[PrimeNeighbors[p]]
    For[k = 0, k <= PrimePi[10^10], k++, If[WeaklyTwinPrime[Prime[k]], Print[Prime[k]]]]

A347424 Digitally delicate truncatable primes: every suffix is prime, changing any one decimal digit always produces a composite number, except the first to zero.

Original entry on oeis.org

7810223, 19579907, 909001523, 984960937, 78406036607, 90124536947, 99020400307, 190002706337, 393086079907, 500708906197, 509000702017, 600180367883, 780430098443, 3534900290107, 5046024021013, 6006006800743, 6009000432797, 9001924501223, 12090900340283
Offset: 1

Views

Author

Marc Morgenegg, Sep 01 2021

Keywords

Comments

These prime numbers are both:
- digitally delicate primes (also called weakly prime numbers) A158124: changing any one decimal digit always produces a composite number, with restriction that first digit may not be changed to a 0 (that means no change of the number of significant digits from its original value).
- left-truncatable primes A033664: every suffix is prime, means repeatedly deleting the most significant digit gives a prime at every step until a single-digit prime remains.

Crossrefs

Programs

  • Python
    from sympy import isprime, primerange
    def is_digitally_delicate(p):
        s = str(p)
        for i in range(len(s)):
            for d in "0123456789":
                if d != s[i] and not (i == int(d) == 0):
                    if isprime(int(s[:i] + d + s[i+1:])): return False
        return True
    def A033664gen(maxdigits):
        yield from [2, 3, 5, 7]
        primestrs, digits, d = ["2", "3", "5", "7"], "0123456789", 1
        while len(primestrs) > 0 and d < maxdigits:
            cands = (d+p for p in primestrs for d in "0123456789")
            primestrs = [c for c in cands if c[0] == "0" or isprime(int(c))]
            yield from sorted(map(int, (p for p in primestrs if p[0] != "0")))
            d += 1
    def afind(maxdigits):
        for p in A033664gen(maxdigits):
            if is_digitally_delicate(p): print(p, end=", ")
    afind(12) # Michael S. Branicky, Sep 01 2021

Extensions

a(3)-a(4) from Amiram Eldar, Sep 01 2021
a(5)-a(19) from Michael S. Branicky, Sep 01 2021

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-8 of 8 results.