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.

A387305 Least k such that the Hamming weight (A000120) of n*k is prime.

Original entry on oeis.org

3, 3, 1, 3, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 19, 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 1, 3, 19, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 1, 9, 3, 1, 1, 1, 1, 7, 1, 5, 3, 1, 1, 3, 3, 1, 19, 1, 1, 67, 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 5, 1, 5, 3, 1, 1, 1, 1, 5, 1, 5, 3
Offset: 1

Views

Author

Pablo Cadena-UrzĂșa, Aug 25 2025

Keywords

Comments

a(n) is always odd.

Examples

			a(1) = 3 because A000120(1) = 1 (not prime), A000120(2) = 1, and A000120(3) = 2 (prime).
a(11) = 1 because A000120(11) = 3 (prime).
a(15) = 19 since 15*19 = 285 and A000120(285) = 5 (prime); for 1 <= k < 19 the value A000120(15*k) is not prime.
		

Crossrefs

Programs

  • Mathematica
    A387305[n_] := Module[{k = -1}, While[!PrimeQ[DigitSum[(k += 2)*n, 2]]]; k];
    Array[A387305, 100] (* Paolo Xausa, Sep 02 2025 *)
  • PARI
    a(n) = {my(k=1); while(!isprime(hammingweight(n*k)), k++); k};
    vector(100, n, a(n))  \\ first 100 terms
    
  • Python
    import sympy as sp
    def a(n, kmax=10**6):
        for k in range(1, kmax + 1):
            if sp.isprime((n*k).bit_count()):
                return k
        return None
    def A(N):
        return [a(n) for n in range(1, N + 1)]

Formula

a(n) = min{k >= 1 : A000120(n*k) is prime}.
a(n) = 1 if A000120(n) is prime (see A052294).
For all m >= 0, a(2^m) = 3.