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.

A342678 a(n) is the number of base-2 lunar primes less than or equal to n.

Original entry on oeis.org

0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 22, 22, 23, 23, 24
Offset: 1

Views

Author

Ya-Ping Lu, Mar 18 2021

Keywords

Comments

a(n) and base-2 lunar prime density, a(n)/n, for some n up to 2^39 are
k n = 2^k a(n) a(n)/n
-- ------------ ------------ ----------
1 2 1 0.5
5 32 11 0.34375
10 1024 323 0.31542...
15 32768 5956 0.35430...
20 1048576 424816 0.40513...
25 33554432 14871345 0.44320...
30 1073741824 502585213 0.46806...
35 34359738368 16593346608 0.48292...
39 549755813888 269325457277 0.48990...
Conjecture: base-2 lunar prime density approaches 0.5 as n tends to infinity, i.e., lim_{n->oo} a(n)/n = 0.5 (see Comments section in A342676).
a(n) is the n-th partial sum of A342704.

Crossrefs

Programs

  • Python
    def addn(m1, m2):
        s1, s2 = bin(m1)[2:].zfill(0), bin(m2)[2:].zfill(0)
        len_max = max(len(s1), len(s2))
        return int(''.join(max(i, j) for i, j in zip(s1.rjust(len_max, '0'), s2.rjust(len_max, '0'))))
    def muln(m1, m2):
        s1, s2, prod = bin(m1)[2:].zfill(0), bin(m2)[2:].zfill(0), '0'
        for i in range(len(s2)):
            k = s2[-i-1]
            prod = addn(int(str(prod), 2), int(''.join(min(j, k) for j in s1), 2)*2**i)
        return prod
    m = 1; m_size = 7; a = 0; L_im = [1]
    while m <= 2**m_size:
        for i in range(2, m + 1):
            im_st = str(muln(i, m)); im = int(im_st, 2); im_len = len(im_st)
            if im_len > m_size: break
            if im not in L_im: L_im.append(im)
        if m not in L_im: a += 1
        print(a); m += 1