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

A108018 a(n) = the number of primes representable as the sum of some subset of the set of first n primes.

Original entry on oeis.org

1, 3, 4, 5, 9, 12, 16, 19, 25, 31, 37, 43, 51, 59, 66, 75, 84, 95, 103, 115, 127, 137, 150, 162, 177, 191, 205, 218, 233, 250, 267, 282, 299, 319, 338, 359, 376, 399, 421, 440, 461, 481, 508, 531, 556, 578, 602, 629, 653, 683, 707, 737, 765, 793, 824, 853, 883
Offset: 1

Views

Author

Max Alekseyev, Sep 08 2006

Keywords

Comments

a(n) = length of n-th row in A256015; A066028(n) = A256015(n,a(n)). - Reinhard Zumkeller, Jun 01 2015

Crossrefs

Cf. A071810 (same count but with multiplicities).

Programs

  • Haskell
    import Data.List (subsequences, nub)
    a108018 = sum . map a010051' . nub . map sum .
              tail . subsequences . flip take a000040_list
    -- Reinhard Zumkeller, Dec 16 2013
  • Mathematica
    (* This program is not suitable to compute a large number of terms. *)
    a[n_] := a[n] = Select[Total /@ Subsets[Table[Prime[i], {i, 1, n}]], PrimeQ] // Union // Length;
    Table[Print[n, " ", a[n]]; a[n], {n, 1, 25}] (* Jean-François Alcover, Mar 12 2019 *)

Extensions

More terms from Alois P. Heinz, Oct 24 2015

A262765 a(n) = the number of ways that at least two distinct primes <= prime(n) sum to a prime.

Original entry on oeis.org

1, 2, 3, 7, 14, 28, 57, 113, 227, 437, 834, 1616, 3143, 6144, 12036, 23467, 45713, 89375, 175722, 346193, 681828, 1344815, 2657630, 5253615, 10374965, 20471599, 40401901, 79871358, 158182869, 313402574, 620776183, 1228390053, 2430853614, 4813878134, 9550070608
Offset: 2

Views

Author

Bob Selcoe, Sep 30 2015

Keywords

Comments

From Bob Selcoe, Oct 02 2015: (Start)
Conjectures:
i. a(n) ~ 2*a(n-1);
ii. a(n) <= 2*a(n-1)+1, a(n) < 2*a(n-1) n>=11;
iii. As n increases to infinity, a(n)/a(n-1) generally increases toward approximately 2, though the limiting ratio must be < 2.
(End)
From Alois P. Heinz, Oct 02 2015: (Start)
a(333) = 2*a(332)+d where d = 608...358 is a 95-digit positive integer.
It is not true that "a(n)/a(n-1) generally increases"; see plot below.
(End)
From Bob Selcoe, Oct 20 2015: (Start)
The plot does, in fact, suggest that a(n)/a(n-1) "generally increases" (i.e., generally a(z*n)/a(z*n-1) > a(n)/a(n-1), when z is sufficiently large). In other words, the peaks and the troughs tend to increase, with peaks tending to be higher than next trough. This behavior is consistent with the observation about "general increase" in conjecture iii, as n increases to infinity. However, the plot does not show that generally a(n)/a(n-1) > a(n+1)/a(n), or that there can't be a maximum value of a(n)/a(n-1) after which all other values decrease (two completely different issues).
Conjecture ii is clearly false since a(n)/(n-1) is slightly > 2 for a few terms 11 <= n <= 400 (n = {333..340}), therefore weakening the observation in conjecture iii that the limiting ratio must be < 2. (End)

Examples

			a(5)=7; prime(5)=11: 2+3=5, 2+5=7; 2+11=13; 2+3+5+7=17; 3+5+11=19; 2+3+7+11=23; 5+7+11=23.
		

Crossrefs

Cf. A000040 (prime numbers), A007504, A071810.

Programs

  • Maple
    s:= proc(n) option remember; `if`(n=0, 0, s(n-1)+ithprime(n)) end:
    b:= proc(n, i, t) option remember; `if`(n=0,
          `if`(t=0, 1, 0), `if`(i<1, 0, b(n, i-1, t) +(p->
          `if`(p>n, 0, b(n-p, i-1, max(0, t-1))))(ithprime(i))))
        end:
    a:= n-> add(`if`(isprime(k), b(k, n, 2), 0), k=5..s(n)):
    seq(a(n), n=2..36);  # Alois P. Heinz, Oct 01 2015
  • Mathematica
    Length@ Select[Total /@ ReplaceAll[Subsets[Prime@ Range@ #], {} -> Nothing], PrimeQ] & /@ Range[2, 21] (* _Michael De Vlieger, Oct 01 2015 *)

Formula

a(n) = A071810(n) - n. - Alois P. Heinz, Oct 23 2015

Extensions

a(10)-a(21) from Michael De Vlieger, Oct 01 2015
a(22)-a(36) from Alois P. Heinz, Oct 01 2015

A339485 Number of subsets of the first n primes whose elements have a prime average.

Original entry on oeis.org

1, 2, 3, 6, 9, 12, 17, 30, 51, 88, 149, 264, 439, 746, 1261, 2234, 4211, 7996, 14899, 28048, 54037, 106442, 208625, 398588, 735365, 1331590, 2421573, 4481896, 8504953, 16497150, 32595915, 64614636, 127968263, 252470776, 495388085, 962475122, 1847742473, 3504948056
Offset: 1

Views

Author

Ilya Gutkovskiy, Dec 06 2020

Keywords

Examples

			a(5) = 9 subsets: {2}, {3}, {5}, {7}, {11}, {3, 7}, {3, 11}, {3, 5, 7} and {3, 7, 11}.
		

Crossrefs

Programs

  • Maple
    b:= proc(n, s, c) option remember; `if`(n=0,
          `if`(c>0 and denom(s)=1 and isprime(s), 1, 0),
           b(n-1, s, c)+b(n-1, (s*c+ithprime(n))/(c+1), c+1))
        end:
    a:= n-> b(n, 0$2):
    seq(a(n), n=1..40);  # Alois P. Heinz, Dec 08 2020
  • Mathematica
    b[n_, s_, c_] := b[n, s, c] = If[n == 0,
         If[c > 0 && Denominator[s] == 1 && PrimeQ[s], 1, 0],
         b[n-1, s, c] + b[n-1, (s*c + Prime[n])/(c+1), c+1]];
    a[n_] := b[n, 0, 0];
    Array[a, 40] (* Jean-François Alcover, Jul 09 2021, after Alois P. Heinz *)
  • Python
    from sympy import prime, isprime
    from itertools import chain, combinations
    def powerset(s): # skip empty set and singletons
        return chain.from_iterable(combinations(s, r) for r in range(2,len(s)+1))
    def a(n):
        out = n  # count all singletons
        for s in powerset([prime(i) for i in range(1, n+1)]):
            ss = sum(s)
            if ss%len(s) == 0:
                if isprime(ss//len(s)): out += 1
        return out
    print([a(n) for n in range(1, 21)]) # Michael S. Branicky, Dec 06 2020
    
  • Python
    from itertools import combinations
    from sympy import prime
    def A339485(n):
        c, primeset2 = n, set(prime(i) for i in range(1,n))
        primeset = primeset2 | {prime(n)}
        for l in range(2,n+1):
            for d in combinations(primeset,l):
                a, b = divmod(sum(d),l)
                if b == 0 and a in primeset2:
                    c += 1
        return c # Chai Wah Wu, Dec 07 2020
    
  • Python
    from functools import lru_cache
    from sympy import sieve, isprime
    @lru_cache(maxsize=None)
    def b(n, s, c):
        if n == 0: return int(c and s%c == 0 and isprime(s//c))
        return b(n-1, s, c) + b(n-1, s+sieve[n], c+1)
    a = lambda n: b(n, 0, 0)
    print([a(n) for n in range(1, 41)]) # Michael S. Branicky, Oct 06 2022

Extensions

a(10)-a(30) from Michael S. Branicky, Dec 06 2020
a(31)-a(34) from Chai Wah Wu, Dec 07 2020
a(35)-a(36) from Michael S. Branicky, Dec 08 2020
a(37)-a(38) from Chai Wah Wu, Dec 08 2020

A339613 Number of sets of distinct primes whose sum is a prime, the largest element of a set is prime(n).

Original entry on oeis.org

1, 2, 2, 2, 5, 8, 15, 30, 57, 115, 211, 398, 783, 1528, 3002, 5893, 11432, 22247, 43663, 86348, 170472, 335636, 662988, 1312816, 2595986, 5121351, 10096635, 19930303, 39469458, 78311512, 155219706, 307373610, 607613871, 1202463562, 2383024521, 4736192475, 9413441133
Offset: 1

Views

Author

Ilya Gutkovskiy, Dec 09 2020

Keywords

Examples

			a(6) = 8 sets: {13}, {3, 7, 13}, {5, 11, 13}, {7, 11, 13}, {2, 3, 5, 13}, {2, 3, 11, 13}, {2, 5, 11, 13} and {2, 3, 5, 7, 11, 13}.
		

Crossrefs

Cf. A000040, A071810 (partial sums), A127542.

Programs

  • Python
    from sympy import prime, isprime
    from functools import lru_cache
    @lru_cache(maxsize=None)
    def b(n, s, c):
      if n == 0:
        if isprime(s): return 1
        return 0
      return b(n-1, s, c) + b(n-1, s+prime(n), c+1)
    a = lambda n: b(n-1, prime(n), 1)
    print([a(n) for n in range(1, 20)]) # Michael S. Branicky, Dec 10 2020

Extensions

a(35)-a(37) from Michael S. Branicky, Dec 09 2020

A364535 a(n) is the number of subsets of the first n primes whose sum is not a prime.

Original entry on oeis.org

1, 1, 1, 3, 9, 20, 44, 93, 191, 390, 787, 1600, 3250, 6563, 13227, 26609, 53484, 107588, 216413, 434894, 872834, 1750938, 3512454, 7043770, 14119562, 28300792, 56733873, 113746102, 228033527, 456999525, 915558925, 1834081043, 3674191081, 7361544506, 14749015536, 29545860199, 59169406092
Offset: 0

Views

Author

Darío Clavijo, Oct 20 2023

Keywords

Crossrefs

Formula

a(n) = 2^n - A071810(n).
a(n) = A000295(n) - A262765(n) + 1 for n > 2.

A385571 Number of subsets of the first n twin primes (A001097) whose sum is a twin prime.

Original entry on oeis.org

1, 2, 3, 5, 8, 13, 22, 37, 64, 119, 227, 450, 884, 1673, 3019, 5113, 8877, 16119, 30250, 57282, 109178, 210547, 412261, 819165, 1641582, 3298602, 6600608, 13150469, 26176431, 52289653, 104981405, 210846036, 420699038, 828442946, 1610436120, 3102364760
Offset: 1

Views

Author

Ilya Gutkovskiy, Jul 03 2025

Keywords

Examples

			a(5) = 8 subsets: {3}, {5}, {7}, {11}, {13}, {3, 5, 11}, {5, 11, 13} and {7, 11, 13}.
		

Crossrefs

Programs

Extensions

a(23)-a(25) from Amiram Eldar, Jul 03 2025
a(26)-a(36) from David Radcliffe, Jul 04 2025

A339556 Number of subsets of the first n primes whose elements have a prime root-mean-square.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 11, 16, 19, 30, 41, 54, 69, 106, 177, 272, 397, 686, 1299, 2416, 4225, 7196, 11701, 20352, 36305, 70134, 132721, 248722, 473391, 894318, 1674923, 3054022, 5452067, 9626552, 16696543, 29086462, 51830095, 96887612, 192393735, 397875694
Offset: 1

Views

Author

Ilya Gutkovskiy, Dec 08 2020

Keywords

Examples

			a(7) = 11 subsets: {2}, {3}, {5}, {7}, {11}, {13}, {17}, {7, 17}, {5, 7, 17}, {7, 13, 17} and {5, 7, 11, 17}.
		

Crossrefs

Extensions

a(10)-a(40) from Alois P. Heinz, Dec 08 2020
Showing 1-7 of 7 results.