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-5 of 5 results.

A342676 a(n) is the number of lunar primes less than or equal to n.

Original entry on oeis.org

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

Views

Author

Ya-Ping Lu, Mar 18 2021

Keywords

Comments

The density of lunar primes seems to approach a nonzero fraction in contrast to that of the classical primes, which approaches zero as n tends to infinity. a(n) and lunar prime density, a(n)/n, for n up to 10^9 are
n 1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000
a(n) 0 0 18 99 1638 22095 264312 3159111 36694950 418286661
a(n)/n 0 0 0.18 0.099 0.164 0.221 0.264 0.316 0.367 0.418
Conjecture 1: Base 10 lunar prime density approaches 0.9 as n tends to infinity, or lim{n->oo} a(n)/n = 0.9.
D. Applegate, M. LeBrun and N. J. A. Sloane conjectured that the number of base b lunar primes with k digits approaches (b-1)^2*b^(k-2) as k tends to infinity. And necessary conditions for a number n to be prime are that it contain b-1 as a digit and (if k > 2) does not end with 0 (see Links). Since the number of base b integers with k digits equals b^k - b^(k-1), the lunar prime density among integers with k digits should be (b-1)^2*b^(k-2)/(b^k - b^(k-1)), which is 1 - 1/b as k -> oo, if the conjecture holds. Note that, as b increases, the limit approaches 1, or lim_{b->oo} lim_{n->oo} a(n)/n = 1. As n tends to infinity, the probability of finding a base b number having a digit of b-1 approaches 100%, and the probability of finding a base b number ending with 0 approaches 1/b. Therefore, essentially all numbers except those ending with 0 are lunar primes as n tends to infinity.
Conjecture 2: Base b lunar prime density approaches 1 - 1/b as n tends to infinity, or lim{n->oo} a(n)/n = 1 - 1/b.

Crossrefs

Programs

  • Python
    def addn(m1, m2):
        s1, s2 = str(m1), str(m2)
        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 = str(m1), str(m2), '0'
        for i in range(len(s2)):
            k = s2[-i-1]
            prod = addn(int(str(prod)), int(''.join(min(j, k) for j in s1))*10**i)
        return prod
    m = 1; m_size = 2; a = 0; L_im = [9]
    while m <= 10**m_size:
        for i in range(1, m + 1):
            if i == 9: continue
            im_st = str(muln(i, m)); im = int(im_st); 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

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

A171145 The sequence of coefficients of a polynomial recursion: p(x,n)=If[Mod[n, 2] == 0, (x + 1)*p(x, n - 1), (x^2 + n*x + 1)^Floor[n/2]].

Original entry on oeis.org

1, 1, 1, 1, 3, 1, 1, 4, 4, 1, 1, 10, 27, 10, 1, 1, 11, 37, 37, 11, 1, 1, 21, 150, 385, 150, 21, 1, 1, 22, 171, 535, 535, 171, 22, 1, 1, 36, 490, 3024, 7539, 3024, 490, 36, 1, 1, 37, 526, 3514, 10563, 10563, 3514, 526, 37, 1, 1, 55, 1215, 13530, 76845, 188001, 76845
Offset: 1

Views

Author

Roger L. Bagula and Gary W. Adamson, Dec 04 2009

Keywords

Comments

Row sums are:
{1, 2, 5, 10, 49, 98, 729, 1458, 14641, 29282, 371293, 742586,...}.
The modulo 2 of this appears to be a staggered Sierpinski-type fractal.

Examples

			{1},
{1, 1},
{1, 3, 1},
{1, 4, 4, 1},
{1, 10, 27, 10, 1},
{1, 11, 37, 37, 11, 1},
{1, 21, 150, 385, 150, 21, 1},
{1, 22, 171, 535, 535, 171, 22, 1},
{1, 36, 490, 3024, 7539, 3024, 490, 36, 1},
{1, 37, 526, 3514, 10563, 10563, 3514, 526, 37, 1},
{1, 55, 1215, 13530, 76845, 188001, 76845, 13530, 1215, 55, 1},
{1, 56, 1270, 14745, 90375, 264846, 264846, 90375, 14745, 1270, 56, 1}
		

Crossrefs

Programs

  • Mathematica
    Clear[p, n, x, a]
    p[x, 1] := 1;
    p[x_, n_] := p[x, n] = If[Mod[n, 2] == 0, (x + 1)*p[x, n - 1], (x^2 + n*x + 1)^Floor[n/2]];
    a = Table[CoefficientList[p[x, n], x], {n, 1, 12}];
    Flatten[a]

Formula

p(x,n)=If[Mod[n, 2] == 0, (x + 1)*p(x, n - 1), (x^2 + n*x + 1)^Floor[n/2]]

A171146 The sequence of coefficients of a polynomial recursion: p(x,n)=If[Mod[n, 2] == 0, (x + 1)*p(x, n - 1), (x^2 + (2*n - 1)*x + 1)^Floor[n/2]] ( correction).

Original entry on oeis.org

1, 1, 1, 1, 5, 1, 1, 6, 6, 1, 1, 18, 83, 18, 1, 1, 19, 101, 101, 19, 1, 1, 39, 510, 2275, 510, 39, 1, 1, 40, 549, 2785, 2785, 549, 40, 1, 1, 68, 1738, 19856, 86995, 19856, 1738, 68, 1, 1, 69, 1806, 21594, 106851, 106851, 21594, 1806, 69, 1, 1, 105, 4415, 93030, 985645
Offset: 1

Views

Author

Roger L. Bagula and Gary W. Adamson, Dec 04 2009

Keywords

Comments

Row sums are:
{1, 2, 7, 14, 121, 242, 3375, 6750, 130321, 260642, 6436343, 12872686...}.

Examples

			{1},
{1, 1},
{1, 5, 1},
{1, 6, 6, 1},
{1, 18, 83, 18, 1},
{1, 19, 101, 101, 19, 1},
{1, 39, 510, 2275, 510, 39, 1},
{1, 40, 549, 2785, 2785, 549, 40, 1},
{1, 68, 1738, 19856, 86995, 19856, 1738, 68, 1},
{1, 69, 1806, 21594, 106851, 106851, 21594, 1806, 69, 1},
{1, 105, 4415, 93030, 985645, 4269951, 985645, 93030, 4415, 105, 1},
{1, 106, 4520, 97445, 1078675, 5255596, 5255596, 1078675, 97445, 4520, 106, 1}
		

Crossrefs

Programs

  • Mathematica
    Clear[p, n, x, a]
    p[x, 1] := 1;
    p[x_, n_] := p[x, n] = If[Mod[n, 2] == 0, (x + 1)*p[x, n - 1], (x^2 + (2*n - 1)*x + 1)^Floor[n/2]];
    a = Table[CoefficientList[p[x, n], x], {n, 1, 12}];
    Flatten[a]

Formula

p(x,n)=If[Mod[n, 2] == 0, (x + 1)*p(x, n - 1), (x^2 + (2*n - 1)*x + 1)^Floor[n/2]]

A171147 The sequence of coefficients of a polynomial recursion: p(x,n)=If[Mod[n, 2] == 0, (x + 1)*p(x, n - 1), (x^2 + (2*n)*x + 1)^Floor[n/2]].

Original entry on oeis.org

1, 1, 1, 1, 6, 1, 1, 7, 7, 1, 1, 20, 102, 20, 1, 1, 21, 122, 122, 21, 1, 1, 42, 591, 2828, 591, 42, 1, 1, 43, 633, 3419, 3419, 633, 43, 1, 1, 72, 1948, 23544, 108870, 23544, 1948, 72, 1, 1, 73, 2020, 25492, 132414, 132414, 25492, 2020, 73, 1, 1, 110, 4845, 106920
Offset: 1

Views

Author

Roger L. Bagula and Gary W. Adamson, Dec 04 2009

Keywords

Comments

Row sums are:
{1, 2, 8, 16, 144, 288, 4096, 8192, 160000, 320000, 7962624, 15925248...}.

Examples

			{1},
{1, 1},
{1, 6, 1},
{1, 7, 7, 1},
{1, 20, 102, 20, 1},
{1, 21, 122, 122, 21, 1},
{1, 42, 591, 2828, 591, 42, 1},
{1, 43, 633, 3419, 3419, 633, 43, 1},
{1, 72, 1948, 23544, 108870, 23544, 1948, 72, 1},
{1, 73, 2020, 25492, 132414, 132414, 25492, 2020, 73, 1},
{1, 110, 4845, 106920, 1185810, 5367252, 1185810, 106920, 4845, 110, 1},
{1, 111, 4955, 111765, 1292730, 6553062, 6553062, 1292730, 111765, 4955, 111, 1}
		

Crossrefs

Programs

  • Mathematica
    Clear[p, n, x, a]
    p[x, 1] := 1;
    p[x_, n_] := p[x, n] = If[Mod[n, 2] == 0, (x + 1)*p[x, n - 1], (x^2 + (2*n)*x + 1)^Floor[n/2]];
    a = Table[CoefficientList[p[x, n], x], {n, 1, 12}];
    Flatten[a]

Formula

p(x,n)=If[Mod[n, 2] == 0, (x + 1)*p(x, n - 1), (x^2 + (2*n)*x + 1)^Floor[n/2]]
Showing 1-5 of 5 results.