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-9 of 9 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

A137985 Complementing any single bit in the binary representation of these primes does not produce a prime number.

Original entry on oeis.org

127, 173, 191, 223, 233, 239, 251, 257, 277, 337, 349, 373, 431, 443, 491, 509, 557, 653, 683, 701, 733, 761, 787, 853, 877, 1019, 1193, 1201, 1259, 1381, 1451, 1453, 1553, 1597, 1709, 1753, 1759, 1777, 1973, 2027, 2063, 2333, 2371, 2447, 2633, 2879, 2917, 2999
Offset: 1

Views

Author

T. D. Noe, Feb 26 2008

Keywords

Comments

If 2^m is the highest power of 2 in the binary representation of the prime p, there is no requirement that p+2^(m+1) be composite. Sequence A065092 imposes this extra requirement. The prime 223 is the first number in this sequence that is not in A065092.
Mentioned Feb 25 2008 by Terence Tao in his blog http://terrytao.wordpress.com. Tao proves that there are an infinite number of these primes in every fixed base.
Digitally delicate primes in base 2. - Marc Morgenegg, Apr 21 2021

Examples

			The numbers produced by complementing each of the 8 bits of 223 are 95, 159, 255, 207, 215, 219, 221 and 222, which are all composite.
		

Crossrefs

Cf. A050249 (analogous base 10 sequence), A186995 (weak primes in base n).
A065092 is a very similar sequence.

Programs

  • Maple
    q:= p-> isprime(p) and not ormap(i->isprime(Bits[Xor](p, 2^i)), [$0..ilog2(p)]):
    select(q, [$2..5000])[];  # Alois P. Heinz, Jul 28 2025
  • Mathematica
    t={}; k=1; While[Length[t]<100, k++; p=Prime[k]; d=IntegerDigits[p,2]; n=Length[d]; i=0; While[iT. D. Noe *)
    isWPbase2[z_] := NestWhile[#*2 &, 2, (# < z && ! PrimeQ@BitXor[z, #] &)] > z; Select[Prime /@ Range[3, PrimePi[10^6]], isWPbase2@# &] (* Terentyev Oleg, Jul 17 2011 *)
    Select[Prime[Range[500]], NoneTrue[BitXor[#, 2^Range[0, BitLength[#] - 1]], PrimeQ] &] (* Paolo Xausa, Apr 23 2025 *)
  • PARI
    f(p)={pow2=1;v=binary(p);L=#v;
    forstep(k=L,1,-1,if(v[k],p-=pow2;if(isprime(p),return(0),p+=pow2),p+=pow2;if(isprime(p),return(0),p-=pow2)); pow2*=2);return(1)}; forprime(p=2,2879,if(f(p), print1(p,", "))) \\ Washington Bomfim, Jan 18 2011
    
  • PARI
    is_A137985(n)=!for(k=1,n,isprime(bitxor(n,k)) && return;k+=k-1) && isprime(n) \\ Note: A bug in early versions of PARI 2.6 (execute "for(i=0,1,i>3 && error(buggy);i=9)" to check) makes that this is is_A065092 rather than is_A137985 as expected. For these versions, replace the upper limit n with n\2. \\ M. F. Hasler, Apr 05 2013
    
  • Python
    from sympy import isprime, primerange
    def ok(p): # p assumed prime
      return not any(isprime((1<Michael S. Branicky, Feb 16 2021

Extensions

Definition clarified by Chai Wah Wu, Jan 03 2019
Name edited by Paolo Xausa, Apr 24 2025

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

A323745 a(n) is the smallest prime that becomes composite if any single digit of its base-n expansion is changed to a different digit (but not to zero).

Original entry on oeis.org

3, 2, 89, 67, 28151, 223, 6211, 2789, 294001, 701, 8399011, 2423, 691063, 243367, 527099, 10513, 2078920243, 10909, 169402249, 2114429, 156760543, 68543, 96733308587, 181141, 121660507, 6139219, 3141223681, 114493
Offset: 2

Views

Author

Jon E. Schoenfield, May 04 2019

Keywords

Comments

This sequence has several terms in common with A186995; if the restriction that no digit can be changed to zero were removed, A186995 would result.
a(30) > 10^10.
The next few terms after a(30) are 356479, 860343287, 399946711, ...

Examples

			a(2)=3 because 3 is prime and its base-2 expansion is 11_2, which cannot have either of its digits changed to a nonzero digit, whereas the only smaller prime, i.e., 2 = 10_2, yields another prime if its 0 digit is changed to a 1.
a(3)=2 because 2 = 2_3 is prime and, in base 3, the only way to change its digit to another (nonzero) digit is to change it to 1_3 = 1, which is nonprime.
a(4)=89 because 89 = 1121_4 is prime, every number that can be obtained by changing one of its digits to another (nonzero) digit is nonprime (1122_4=90, 1123_4=91, 1111_4=85, 1131_4=93, 1221_4=105, 1321_4=121, 2121_4=153, 3121_4=217), and there is no prime smaller than 89 that has this property.
a(18)=2078920243 because 2078920243 = 3723de91_18 (where the letters d and e represent the base-18 digits whose values are 13 and 14, respectively), and each of the 128 other base-18 numbers that can be obtained by changing one of its eight digits to another (nonzero) digit is nonprime, and no smaller prime has this property.
		

Crossrefs

Cf. A186995.

Programs

  • Python
    from sympy import isprime, nextprime
    from sympy.ntheory import digits
    def A323745(n):
        p = 2
        while True:
            m = 1
            for j in digits(p,n)[:0:-1]:
                for k in range(1,n):
                    if k!=j and isprime(p+(k-j)*m):
                        break
                else:
                    m *= n
                    continue
                break
            else:
                return p
            p = nextprime(p) # Chai Wah Wu, Mar 25 2024

Formula

a(n) <= A186995(n). - Chai Wah Wu, Mar 25 2024

A370531 The smallest number in base n such that two digits (and no fewer) need to be changed to get a prime.

Original entry on oeis.org

8, 24, 24, 90, 90, 119, 200, 117, 200, 319, 528, 1131, 1134, 525, 1328, 1343, 1332, 1330, 1340, 2478, 7260, 1334, 5352, 4300, 5954, 4833, 13188, 8468, 10800, 15686, 11744, 19338, 19618, 22575, 19620, 15688, 28234, 19617, 25480, 31406, 19614, 40291, 25476, 31410
Offset: 2

Views

Author

Don N. Page, Feb 21 2024

Keywords

Comments

Any digit, including the most significant, can be changed to 0.
If one defines the Prime-Erdős-Number PEN(n, k) in base n of a number k to be the minimum number of the base-n digits of k that must be changed to get a prime, then a(n) is the smallest number k such that PEN(n, k) = 2.
Adding preceding 0's to be changed does not appear to change any of the entries given below.

Examples

			a(2) = 8 = 1000_2 can be changed to the prime 1011_2 (11 in decimal) by changing the last two digits.  Although 4 = 100_2 can be changed to the prime 111_2 by changing two digits, it can also be changed to the prime 101_2 by only one base-2 digit, so 4 is not a(2).
a(3) =  24 = 220_3 can be changed to 212_3 = 23. 24 is not prime and no single base-3 digit change works.
a(4) =  24 = 120_4 can be changed to 113_4 = 23.
a(5) =  90 = 330_5 -> 324_5 =  89.
a(6) =  90 = 230_6 -> 225_6 =  89.
a(7) = 119 = 230_7 -> 221_7 = 113.
a(8) = 200 = 310_8 -> 307_8 = 199.
a(9) = 117 = 140_9 -> 135_9 = 113.
Often, there are alternative ways to change two digits to get alternative primes, but for each a(n), there is not any way to get a prime by changing 0 or 1 digits in base n.
		

Crossrefs

Programs

  • Python
    from sympy import isprime
    from sympy.ntheory import digits
    from itertools import combinations, count, product
    def fromdigits(d, b): return sum(di*b**i for i, di in enumerate(d[::-1]))
    def PEN(base, k):
        if isprime(k): return 0
        d = digits(k, base)[1:]
        for j in range(1, len(d)+1):
            for c in combinations(range(len(d)), j):
                for p in product(*[[i for i in range(base) if i!=d[c[m]]] for m in range(j)]):
                    dd = d[:]
                    for i in range(j): dd[c[i]] = p[i]
                    if isprime(fromdigits(dd, base)): return j
    def a(n): return next(k for k in count(n) if PEN(n, k) == 2)
    print([a(n) for n in range(2, 32)]) # Michael S. Branicky, Feb 21 2024

Extensions

a(11) and beyond from Michael S. Branicky, Feb 21 2024

A371475 Smallest weak prime in base 2n+1.

Original entry on oeis.org

2, 83, 223, 2789, 3347, 4751, 484439, 10513, 10909, 2823167, 68543, 181141, 6139219, 488651, 356479, 399946711, 22549349, 8371249, 660040873, 12088631, 3352003, 234606268969, 84343813, 82751411, 153722088497, 141451831, 11085190183, 350552595007, 535946951, 658716229
Offset: 1

Views

Author

Chai Wah Wu, Mar 24 2024

Keywords

Comments

Bisection of A186995. Smallest weak prime in odd bases appear to be relatively smaller than smallest weak prime in even bases. This could be due to the fact that for an odd base and an odd prime, any digit change with an odd difference from the original digit results in an even number and thus not prime, so only digit changes with an even difference need to be checked for primality, whereas for an even base, all digit changes need to be checked.
Smallest weak prime in odd bases of the form 6k+3 appear to be relatively larger than smallest weak prime in other odd bases.

Crossrefs

Cf. A186995, A050249 (base 10), A137985 (base 2).

Programs

  • Python
    from sympy import isprime, nextprime
    from sympy.ntheory import digits
    def A371475(n):
        if n == 1: return 2
        p, r = 5, (n<<1)+1
        while True:
            s = digits(p,r)[1:]
            l = len(s)
            for i,j in enumerate(s[::-1]):
                m = r**i
                for k in range(j&1,r,2):
                    if k!=j and isprime(p+(k-j)*m):
                        break
                else:
                    continue
                break
            else:
                return p
            p = nextprime(p)

Formula

a(n) = A186995(2*n+1).

Extensions

a(22)-a(27) from Michael S. Branicky, Apr 01 2024
a(28)-a(30) from Michael S. Branicky, Apr 06 2024

A326609 Largest minimal prime in base n (written in base 10).

Original entry on oeis.org

3, 13, 5, 3121, 5209, 2801, 76695841, 811, 66600049, 29156193474041220857161146715104735751776055777, 388177921
Offset: 2

Views

Author

Richard N. Smith, Jul 13 2019

Keywords

Comments

a(13) is (probably) 13^32020*8+183, it has 35670 digits, a(14) = 14^85*4+65, it has 99 digits, a(15) = (15^106*66-619)/7, it has 126 digits, a(16) = 16^3544*9+145, it has 4269 digits.
a(17) is the smallest prime of the form (4105*17^k-9)/16 if it exists, otherwise (probably) (73*17^111333-9)/16 (136991 digits), a(18) = 18^31*304+1 (42 digits).
Other known terms: a(20) = (20^449*16-2809)/19 (585 digits), a(22) = 22^763*20+7041 (1026 digits), a(23) is (probably) (23^800873*106-7)/11 (1090573 digits), a(24) = (24^99*512-121)/23 (138 digits), a(30) = 30^1023*12+1 (1513 digits), a(42) = (42^487*27-1093)/41 (791 digits).
a(19) is the smallest prime of the form (15964*19^k-1)/3 if it exists, otherwise (probably) (904*19^110984-1)/3 (141924 digits), a(21) is the smallest prime of the form 16*21^k+335 if it exists, otherwise (probably) (51*21^479149-1243)/4 (633542 digits).

Crossrefs

Cf. A071062 (base 10 minimal primes), A110600 (base 12 minimal primes).
Cf. A293142 (largest non-repunit permutable prime), A317689 (largest non-repunit circular prime), A103443 (largest left-truncatable prime), A023107 (largest right-truncatable prime), A323137 (largest two-sided prime), A084738 (smallest repunit prime), A186995 (smallest weakly prime).

A371509 a(n) is the smallest prime that becomes composite if any single digit of its base-(2n+1) expansion is changed to a different digit (but not to zero).

Original entry on oeis.org

2, 67, 223, 2789, 701, 2423, 243367, 10513, 10909, 2114429, 68543, 181141, 6139219, 114493, 356479, 399946711, 22549349, 8371249, 660040873, 12088631, 3352003
Offset: 1

Views

Author

Chai Wah Wu, Mar 25 2024

Keywords

Comments

Bisection of A323745. a(n) <= A371475(n) with equality for some values of n.

Crossrefs

Programs

  • Python
    from sympy import isprime, nextprime
    from sympy.ntheory import digits
    def A371509(n):
        if n == 1: return 2
        p, r = 5, (n<<1)+1
        while True:
            m = 1
            for j in digits(p,r)[:0:-1]:
                for k in range(2-(j&1),r,2):
                    if k!=j and isprime(p+(k-j)*m):
                        break
                else:
                    m *= r
                    continue
                break
            else:
                return p
            p = nextprime(p)

Formula

a(n) = A323745(2n+1).
a(n) <= A371475(n).

A370572 The smallest number which in base n requires 3 digit changes to convert k into a prime.

Original entry on oeis.org

84, 1953, 34560, 7000485, 354748446, 77478704205, 1878528135128, 48398467146642
Offset: 2

Views

Author

Michael S. Branicky and Don N. Page, Feb 22 2024

Keywords

Comments

Leading digits may be changed to 0.
a(6)-a(9) converted from A133219.
a(10) <= 977731833235239280 is also from A133219, but not proved minimal.

Crossrefs

Showing 1-9 of 9 results.