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

A186995 Smallest weak prime in base n.

Original entry on oeis.org

127, 2, 373, 83, 28151, 223, 6211, 2789, 294001, 3347, 20837899, 4751, 6588721, 484439, 862789, 10513, 2078920243, 10909, 169402249, 2823167, 267895961, 68543, 1016960933671, 181141, 121660507, 6139219, 11646280537, 488651
Offset: 2

Views

Author

T. D. Noe, Mar 01 2011

Keywords

Comments

In base b, a prime is said to be weakly prime if changing any digit produces only composite numbers. Tao proves that in any fixed base there are an infinite number of weakly primes.
In particular, changing the leading digit to 0 must produce a composite number. These are also called weak primes, weakly primes, and isolated primes. - N. J. A. Sloane, May 06 2019
a(24) > 10^11. - Jon E. Schoenfield, May 06 2019
a(30) > 2*10^12. - Giovanni Resta, Jun 17 2019
a(30) > 10^13. - Dana Jacobsen, Mar 25 2023
a(n) appears to be relatively smaller for n odd than for n even. For instance, a(31) = 356479, a(33) = 399946711, a(35) = 22549349, a(37) = 8371249. a(n) for n of the form 6k+3 appear to be relatively larger than a(n) for other odd n. a(n) for n of the form 6k appear to be relatively larger than a(n) for other even n. - Chai Wah Wu, Mar 24 2024

Crossrefs

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

Programs

  • Mathematica
    isWeak[n_, base_] := Module[{d, e, weak, num}, d = IntegerDigits[n, base]; weak = True; Do[e = d; e[[i]] = j; num = FromDigits[e, base]; If[num != n && PrimeQ[num], weak = False; Break[]], {i, Length[d]}, {j, 0, base - 1}]; weak]; Table[p = 2; While[! isWeak[p, n], p = NextPrime[p]]; p, {n, 2, 16}]
  • Python
    from itertools import count
    from sympy import isprime
    from sympy.ntheory.digits import digits
    def fromdigits(d, b):
        n = 0
        for di in d: n *= b; n += di
        return n
    def h1(n, b): # hamming distance 1 neighbors of n in base b
        d = digits(n, b)[1:]; L = len(d)
        yield from (fromdigits(d[:i]+[c]+d[i+1:], b) for c in range(b) for i in range(L) if c!=d[i])
    def ok(n, b): return isprime(n) and all(not isprime(k) for k in h1(n, b))
    def a(n): return next(k for k in count(2) if ok(k, n))
    print([a(n) for n in range(2, 12)]) # Michael S. Branicky, Jul 31 2022
    
  • Python
    from sympy import isprime, nextprime
    from sympy.ntheory import digits
    def A186995(n):
        p = 2
        while True:
            s = digits(p,n)[1:]
            l = len(s)
            for i,j in enumerate(s[::-1]):
                m = n**i
                for k in range(n):
                    if k!=j and isprime(p+(k-j)*m):
                        break
                else:
                    continue
                break
            else:
                return p
            p = nextprime(p) # Chai Wah Wu, Mar 24 2024

Extensions

a(17)-a(23) from Terentyev Oleg, Sep 04 2011
a(24)-a(29) from Giovanni Resta, Jun 17 2019

A065092 Primes with property that when written in base two complementing any single bit yields a composite number.

Original entry on oeis.org

127, 173, 191, 233, 239, 251, 277, 337, 349, 373, 431, 443, 491, 557, 653, 683, 701, 733, 761, 1019, 1193, 1201, 1381, 1453, 1553, 1597, 1709, 1753, 1759, 1777, 2027, 2063, 2333, 2371, 2447, 2633, 2879, 2999, 3083, 3181, 3209, 3313, 3593, 3643, 3767, 3779, 3851
Offset: 1

Views

Author

Robert G. Wilson v, Nov 10 2001

Keywords

Comments

Also known as singularly dead end primes.
In contrast to the primes listed in A137985 (which contains, e.g., the additional term 223), the terms listed here are required to yield a composite also when prefixed with an ("additional") binary digit 1. - M. F. Hasler, Apr 05 2013

Examples

			127 is in the sequence because 127d becomes 1111111b. "Changing a 1 to a 0 [from right to left] yields rooms 126, 125, 123, 119, 111, 95, or 62, all of which are composite. Furthermore, adding a digit 1 to the left of this number produces, 255 = 11111111b which is also composite. However, this room is not completely isolated from the maze because one can drop in from room 383d = 101111111b." Paulsen.
		

Crossrefs

Cf. A137985.

Programs

  • Maple
    q:= p-> isprime(p) and not ormap(i-> isprime(Bits[Xor](p, 2^i)), [$0..ilog2(p)+1]):
    select(q, [$2..5000])[];  # Alois P. Heinz, Jul 28 2025
  • Mathematica
    Do[d = Prepend[ IntegerDigits[ Prime[n], 2], 0]; l = Length[d]; k = 1; While[k < l && !PrimeQ[ FromDigits[ If[d[[k]] == 1, ReplacePart[d, 0, k], ReplacePart[d, 1, k]], 2]], k++ ]; If[k == l, Print[ Prime[n]]], {n, 2, 500} ]
  • PARI
    f(p)=
    {
      pow2=2;  v=binary(p); L=#v-1;
      forstep(k=L,1,-1,
        if(v[k]==0, x=p+pow2, x=p-pow2);
        if(isprime(x), return(0));
        pow2*=2
      );
      if(isprime(p+pow2), return(0)); return(1)
    };
    forprime(p=5,3767, if(f(p), print1(p, ", "))) \\ Washington Bomfim, Jan 16 2011
    
  • PARI
    /* needs ver. >= 2.6 */ is_A065092(n)={!for(k=1,n,isprime(bitxor(n,k))&return;k+=k-1)&isprime(n)} \\ Note the strange behavior of the for() loop w.r.t. the upper limit. In PARI versions up to 2.4, the increment must take place at the beginning of the loop, viz "k>2 & k+=k-2" BEFORE isprime(), as to cover k=2^ceil(log[2](n)). - 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, Jul 26 2022

Extensions

Links fixed & added by M. F. Hasler, Apr 05 2013

A292348 "Pri-most" numbers: the majority of bits in the binary representation of these numbers satisfy the following: complementing this bit produces a prime number.

Original entry on oeis.org

6, 7, 15, 19, 21, 23, 27, 43, 45, 63, 71, 75, 77, 81, 99, 101, 105, 111, 135, 147, 159, 165, 175, 183, 189, 195, 225, 231, 235, 237, 243, 255, 261, 273, 285, 309, 315, 335, 345, 357, 363, 375, 381, 423, 435, 483, 495, 507, 553, 555, 573, 585, 645, 663, 669, 675
Offset: 1

Views

Author

Alex Ratushnyak, Dec 07 2017

Keywords

Comments

Conjecture: the sequence is infinite.

Examples

			23 is 10111 in binary, 23 XOR {1,2,4,8,16} = {22,21,19,31,7}, three times a prime was produced, namely 19,31,7, versus two composites, 22 and 21. More primes than composites, therefore 23 is a term.
		

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; local k; for k from 1+a(n-1) while add(
         `if`(isprime(Bits[Xor](k, 2^i)), 1, -1), i=0..ilog2(k))<1 do od; k
        end: a(0):=0:
    seq(a(n), n=1..100);  # Alois P. Heinz, Dec 07 2017
  • Mathematica
    okQ[n_] := Module[{cnt, f}, cnt = Thread[f[n, 2^Range[0, Log[2, n] // Floor]]] /. f -> BitXor // PrimeQ; Count[cnt, True] > Length[cnt]/2];
    Select[Range[1000], okQ] (* Jean-François Alcover, Oct 04 2019 *)
  • Python
    from sympy import isprime
    for i in range(1000):
      delta = 0  # foundPrime - nonPrime
      bit = 1
      while  bit <= i:
        if isprime(i^bit): delta += 1
        else:              delta -= 1
        bit*=2
      if delta > 0:  print(str(i), end=',')

A320102 Primes where changing any single bit in the binary representation never results in a smaller prime.

Original entry on oeis.org

2, 5, 17, 41, 73, 97, 127, 137, 149, 173, 191, 193, 223, 233, 239, 251, 257, 277, 281, 307, 331, 337, 349, 373, 389, 401, 431, 443, 491, 509, 521, 547, 557, 569, 577, 599, 617, 641, 653, 683, 701, 719, 733, 757, 761, 787, 809, 821, 839, 853, 877, 881, 907, 919, 977, 997, 1019, 1033, 1087, 1093, 1153
Offset: 1

Views

Author

Paul V. McKinney, Oct 06 2018

Keywords

Comments

Rooms in Paulsen's prime number maze that are not connected to any room with a lesser room number.
"The prime number maze is a maze of prime numbers where two primes are connected if and only if their base 2 representations differ in just one bit." - William Paulsen (A065123).
If k is prime and the bit 2^m in k is 0 then 2^m+k is not in the sequence.
If k is in the sequence then 2^m+k is not where the bit 2^m in k is 0. - David A. Corneth, Oct 09 2018

Examples

			7 is not in the sequence because there is a way to change only one single bit of its binary representation that results in a prime smaller than 7 {1(1)1,(1)11} {5,3}.
41 is in the sequence because changing any single bit of its binary representation binary representation never results in a smaller prime {10100(1),10(1)001,(1)01001} {40,25,9}.
		

Crossrefs

Programs

  • FORTRAN
    See "Links" for program.
    
  • Mathematica
    q[p_] := PrimeQ[p] && AllTrue[2^(-1 + Position[Reverse @ IntegerDigits[p, 2], 1] // Flatten), !PrimeQ[p - #] &]; Select[Range[1000], q] (* Amiram Eldar, Jan 13 2022 *)
  • PARI
    is(n) = if(!isprime(n), return(0)); b = binary(n); for(i=1, #b, if(b[i]==1, if(isprime(n-2^(#b-i)), return(0)))); 1 \\ David A. Corneth, Oct 09 2018
    
  • Python
    from sympy import isprime
    def ok(n):
        if not isprime(n): return False
        onelocs = (i for i, bi in enumerate(bin(n)[2:][::-1]) if bi == '1')
        return not any(isprime(n-2**k) for k in onelocs)
    print([k for k in range(1154) if ok(k)]) # Michael S. Branicky, Jan 10 2022

A322743 Least composite such that complementing one bit in its binary representation at a time produces exactly n primes.

Original entry on oeis.org

8, 4, 6, 15, 21, 45, 111, 261, 1605, 1995, 4935, 8295, 69825, 268155, 550725, 4574955, 13996605, 12024855, 39867135, 398467245, 1698754365, 16351800465, 72026408685, 120554434875
Offset: 0

Views

Author

Paolo P. Lava, Dec 24 2018

Keywords

Examples

			a(1) = 4 because 4 in base 2 is 100 and 000 is 0, 110 is 6 and 101 is 5: hence only one prime.
a(2) = 6 because 6 in base 2 is 110 and 010 is 2, 100 is 4 and 111 is 7: hence two primes.
		

Crossrefs

Programs

  • Maple
    a:= proc(n) local k; for k from 2^n+1 while isprime(k) or n<>add(
          `if`(isprime(Bits[Xor](k, 2^j)), 1, 0), j=0..ilog2(k)) do od; k
        end:
    seq(a(n), n=0..12);  # Alois P. Heinz, Jan 03 2019
  • Python
    from sympy import isprime
    def A322743(n):
        i = 4 if n <= 1 else 2**n+1
        j = 1 if n <= 2 else 2
        while True:
            if not isprime(i):
                c = 0
                for m in range(len(bin(i))-2):
                    if isprime(i^(2**m)):
                        c += 1
                    if c > n:
                        break
                if c == n:
                    return i
            i += j # Chai Wah Wu, Jan 03 2019

Formula

From Chai Wah Wu, Jan 03 2019: (Start)
a(n) >= 2^n+1, if it exists. a(n) is odd for n > 2, if it exists.
It is clear these are true for n <= 2. Suppose n > 2. If a(n) is even, then complementing any bits that is not LSB or MSB will result in an even nonprime number. If a(n) is odd, then complementing the LSB will result in an even nonprime number. So either case shows that a(n) has n+1 or more binary bits. It also shows that a(n) must be odd.
Conjecture: a(n) mod 10 == 5 for n > 7. (End)
a(24) <= 794688308295. - Michael S. Branicky, Apr 25 2025

Extensions

Definition clarified by Chai Wah Wu, Jan 03 2019
a(19) added and a(0) corrected by Rémy Sigrist, Jan 03 2019
a(20)-a(23) from Giovanni Resta, Jan 03 2019

A352942 Let p = prime(n); a(n) = number of primes q with same number of binary digits as p that can be obtained from p by changing one binary digit.

Original entry on oeis.org

1, 1, 1, 1, 0, 0, 1, 2, 2, 1, 2, 1, 1, 3, 1, 2, 1, 1, 2, 3, 1, 1, 1, 1, 2, 3, 2, 0, 1, 1, 0, 2, 1, 2, 3, 1, 1, 4, 1, 0, 1, 1, 0, 1, 3, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 2, 2, 0, 3, 2, 1, 1, 2, 2, 1, 1, 0, 3, 0, 0, 2, 2, 0, 2, 2, 2, 3, 2, 2, 0, 2, 0, 1, 2, 0, 1
Offset: 1

Views

Author

Michael S. Branicky, May 11 2022

Keywords

Comments

a(n) is also the degree of prime(n) in the graph P(A070939(prime(n)), 2), defined in A145667.

Examples

			prime(1) = 2, in binary 10, has one neighbor 11 in P(2, 2), so a(1) = 1.
prime(14) = 43, in binary 101011, has neighbors 101001 (41), 101111 (47), 111011 (59), so a(14) = 3.
		

Crossrefs

Programs

  • Maple
    a:= n-> (p-> nops(select(isprime, {seq(Bits[Xor]
            (p, 2^i), i=0..ilog2(p)-1)})))(ithprime(n)):
    seq(a(n), n=1..100);  # Alois P. Heinz, May 11 2022
  • Mathematica
    A352942[n_] := Count[BitXor[#, 2^Range[0, BitLength[#] - 2]], _?PrimeQ] & [Prime[n]];
    Array[A352942, 100] (* Paolo Xausa, Apr 23 2025 *)
  • Python
    from sympy import isprime, sieve
    def neighs(s):
        digs = "01"
        ham1 = (s[:i]+d+s[i+1:] for i in range(len(s)) for d in digs if d!=s[i])
        yield from (h for h in ham1 if h[0] != '0')
    def a(n):
        return sum(1 for s in neighs(bin(sieve[n])[2:]) if isprime(int(s, 2)))
    print([a(n) for n in range(1, 88)])

Formula

a(n) = deg(prime(n)) in P(A070939(prime(n)), 2) (see A145667).

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

A292349 Pri-most primes: primes p such that the majority of bits in the binary representation of p satisfy the following: complementing this bit produces a prime number.

Original entry on oeis.org

7, 19, 23, 43, 71, 101
Offset: 1

Views

Author

Alex Ratushnyak, Dec 07 2017

Keywords

Comments

Primes in A292348.
Conjecture: the sequence is finite.
Any further terms are > 10^12. - Lucas A. Brown, Oct 05 2024

Crossrefs

Programs

  • Mathematica
    Select[Prime@ Range[10^5], Function[n, Function[d, 2 Count[Array[FromDigits[#, 2] &@ MapAt[Mod[# + 1, 2] &, d, #] &, Length@ d], ?PrimeQ] > Length@ d]@ IntegerDigits[n, 2]]] (* _Michael De Vlieger, Dec 08 2017 *)
  • Python
    from sympy import isprime, primerange
    for i in primerange(1, 1000):
      delta = 0
      bit = 1
      while  bit <= i:
        if isprime(i^bit): delta += 1
        else:              delta -= 1
        bit*=2
      if delta > 0:  print(str(i), end=',')

A385245 Primes that are no longer prime if in their binary representation any single bit is flipped but stay prime if a 1 bit is prepended.

Original entry on oeis.org

223, 257, 509, 787, 853, 877, 1259, 1451, 1973, 2917, 3511, 5099, 6287, 6521, 7841, 8171, 8923, 9319, 10567, 11353, 12517, 12637, 12763, 13687, 14107, 14629, 15217, 15607, 16943, 17519, 18089, 18593, 18743, 19139, 20183, 20393, 20639, 21701, 22943, 26591, 26891
Offset: 1

Views

Author

Alois P. Heinz, Jul 28 2025

Keywords

Examples

			257 = 100000001_2 and 769 = 1100000001_2 are primes and 256, 259, 261, 265, 273, 289, 321, 385, 1 are not prime. So 257 is a term.
		

Crossrefs

Set difference of A137985 and A065092.

Programs

  • Maple
    q:= p-> (m-> andmap(isprime, [p, 2^(m+1)+p]) and not ormap
            (i->isprime(Bits[Xor](p, 2^i)), [$0..m]))(ilog2(p)):
    select(q, [$2..27000])[];
  • Mathematica
    Select[Prime[Range[3000]], PrimeQ[2^BitLength[#] + #] && NoneTrue[BitXor[#, 2^Range[0, BitLength[#] - 1]], PrimeQ] &] (* Paolo Xausa, Aug 05 2025 *)

Formula

{ A137985 } minus { A065092 }.
Showing 1-10 of 10 results.