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.

Previous Showing 11-14 of 14 results.

A145671 a(n) = number of components of the graph P(n,3) (defined in Comments).

Original entry on oeis.org

1, 2, 4, 8, 15, 32, 88, 209, 539, 1403, 3698, 9962, 26447, 71579, 196590, 541473, 1501720, 4186566, 11737617, 33005599, 93296302
Offset: 1

Views

Author

W. Edwin Clark, Mar 17 2009

Keywords

Comments

Let H(n,b) be the Hamming graph whose vertices are the sequences of length n over the alphabet {0,1,...,b-1} with adjacency being defined by having Hamming distance 1. Let P(n,b) be the subgraph of H(n,b) induced by the set of vertices which are base b representations of primes with n digits (not allowing leading 0 digits).

Crossrefs

Extensions

a(11)-a(19) from Max Alekseyev, May 12 2011
a(20)-a(21) from Max Alekseyev, Dec 23 2024

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

A383271 Number of primes (excluding n) that may be generated by replacing any binary digit of n with a digit from 0 to 1.

Original entry on oeis.org

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

Views

Author

Michael S. Branicky, Apr 21 2025

Keywords

Comments

Also, the number of prime neighbors of n in H(A070939(n), 2), where H(k, b) is the Hamming graph whose vertices are the sequences of length k over the alphabet {0,1,...,b-1} with adjacency being defined by having Hamming distance 1 (see A145667).
Prepending 1 is not allowed.

Examples

			a(3) = 1 since 3 = 11_2 can be changed to 10_2 = 2, which is prime.
a(5) = 1 since 5 = 101_2 can be changed to 001_2 = 1, 111_2 = 7 (prime), or 100_2 = 4.
a(6) = 2 since 6 = 110_2 can be changed to 010_2 = 2 (prime), 100_2 = 4, or 111_2 = 7 (prime).
a(7) = 2 since 7 = 111_2 can be changed to 011_2 = 3 (prime), 101_2 = 5 (prime), or 110_2 = 6.
		

Crossrefs

Base-2 analog of A209252.

Programs

  • Maple
    a:= n-> nops(select(isprime, [seq(Bits[Xor](2^i, n), i=0..ilog2(n))])):
    seq(a(n), n=0..100);  # Alois P. Heinz, Apr 23 2025
  • Mathematica
    A383271[n_] := Count[BitXor[n, 2^Range[0, BitLength[n] - 1]], _?PrimeQ];
    Array[A383271, 100, 0] (* Paolo Xausa, Apr 23 2025 *)
  • Python
    from gmpy2 import is_prime
    def a(n):
        if n == 0:
            return 0
        if n&1 == 0:
            return int(is_prime(n + 1)) + int(1<<(n.bit_length()-1)^n == 2)
        mask, c = 1, 0
        for i in range(n.bit_length()):
            if is_prime(mask^n):
                c += 1
            mask <<= 1
        return c
    print([a(n) for n in range(90)])

A353738 Length of longest n-digit optimal prime ladder (base 2).

Original entry on oeis.org

0, 2, 2, 1, 5, 3, 7, 5, 15, 15, 19, 24, 39, 48, 35, 64, 57, 51, 59, 61, 67, 61, 61
Offset: 1

Views

Author

Michael S. Branicky, May 09 2022

Keywords

Comments

A prime ladder (in base b) starts with a prime, ends with a prime, and each step produces a new prime by changing exactly one base-b digit.
A shortest such construct between two given primes is optimal.
Analogous to a word ladder (see Wikipedia link).
Here, n-digit primes do not allow leading 0 digits.
If all n-digit primes are disconnected, a(n) = 1; if there are no n-digit primes, a(n) = 0.

Examples

			There are no 1-digit primes in base 2, so a(1) = 0.
The 2-digit optimal prime ladder 10 - 11 is tied for the longest amongst 2-digit primes in binary, so a(2) = 2.
The 3-digit optimal prime ladder 101 - 111 is tied for the longest amongst 3-digit primes in binary, so a(3) = 2.
The only 4-digit primes in binary, 1011 and 1101, are disconnected, so a(3) = 1.
The 5-digit optimal prime ladder 10001 - 10011 - 10111 - 11111 - 11101 is tied for the longest amongst 5-digit primes in binary, so a(5) = 5.
		

Crossrefs

Formula

a(n) is the number of vertices of a longest shortest path in the graph G = (V, E), where V = {n-digit base-2 primes} and E = {(v, w) | H_2(v, w) = 1}, where H_b is the Hamming distance in base b.

Extensions

a(23) from Michael S. Branicky, May 21 2022
Previous Showing 11-14 of 14 results.