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

A089819 Number of subsets of {1,2,...,n} containing no primes.

Original entry on oeis.org

2, 2, 2, 4, 4, 8, 8, 16, 32, 64, 64, 128, 128, 256, 512, 1024, 1024, 2048, 2048, 4096, 8192, 16384, 16384, 32768, 65536, 131072, 262144, 524288, 524288, 1048576, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 33554432, 67108864
Offset: 1

Views

Author

Reinhard Zumkeller, Nov 12 2003

Keywords

Comments

Equivalently, the number of subsets of {1,2,...,n} such that the product of the elements is square, where the empty set is defined to have a product of 1. - Peter Kagey, Nov 18 2017

Examples

			a(6)=8 subsets of {1,2,3,4,5,6} contain no prime: {1,4,6}, {4,6}, {1,6}, {1,4}, {6}, {4}, {1} and the empty set.
a(7) = 8 as 2^(7 - PrimePi(7)) = 2^(7-4) = 8.
		

Crossrefs

Programs

Formula

a(n) = 2^(n-PrimePi(n)), with PrimePi = A000720.
a(n) = Product_{k=1..n} (2-A010051(k)) = A089818(n,0) = A000079(n) - A089820(n).
a(n) = 2^(1-A010051(n))*a(n-1). - Robert Israel, Nov 22 2017

A089822 Number of subsets of {1,.., n} containing exactly two primes.

Original entry on oeis.org

0, 0, 2, 4, 12, 24, 48, 96, 192, 384, 640, 1280, 1920, 3840, 7680, 15360, 21504, 43008, 57344, 114688, 229376, 458752, 589824, 1179648, 2359296, 4718592, 9437184, 18874368, 23592960, 47185920, 57671680, 115343360, 230686720
Offset: 1

Views

Author

Reinhard Zumkeller, Nov 12 2003

Keywords

Examples

			a(5)=12 subsets of {1,2,3,4,5} contain exactly two primes: {2,3}, {2,5}, {3,5}, {1,2,3}, {1,2,5}, {1,3,5}, {2,3,4}, {2,4,5}, {3,4,5}, {1,2,3,4}, {1,2,4,5} and {1,3,4,5}.
		

Crossrefs

Programs

  • Maple
    N:= 100: # for a(1)..a(N)
    V:= Vector(N):
    p:= 1: n:= 1: pi:= 0:
    while n <= N do
      p:= nextprime(p);
      for n from n to min(N,p-1) do
        V[n]:= pi*(pi-1)*2^(n-pi)/2;
      od;
      pi:= pi+1;
      n:= p;
    od:
    convert(V,list); # Robert Israel, Jul 14 2019
    # second Maple program:
    b:= proc(n, c) option remember; `if`(n=0, `if`(c=0, 1, 0),
         `if`(c<0, 0, b(n-1, c)+b(n-1, c-`if`(isprime(n), 1, 0))))
        end:
    a:= n-> b(n, 2):
    seq(a(n), n=1..42);  # Alois P. Heinz, Dec 19 2019
  • Mathematica
    b[n_, c_] := b[n, c] = If[n == 0, If[c == 0, 1, 0], If[c < 0, 0, b[n-1, c] + b[n-1, c - If[PrimeQ[n], 1, 0]]]];
    a[n_] := b[n, 2];
    Array[a, 42] (* Jean-François Alcover, May 30 2020, after Alois P. Heinz *)

Formula

a(n) = (pi(n)*(pi(n)-1)*2^(n-pi(n)))/2, with pi = A000720.
a(n) = A000217(A000720(n)-1)*A089819(n);
for n>2: a(n) = A089818(n,2).

A089820 Number of subsets of {1,..,n} containing at least one prime.

Original entry on oeis.org

0, 2, 6, 12, 28, 56, 120, 240, 480, 960, 1984, 3968, 8064, 16128, 32256, 64512, 130048, 260096, 522240, 1044480, 2088960, 4177920, 8372224, 16744448, 33488896, 66977792, 133955584, 267911168, 536346624, 1072693248, 2146435072, 4292870144, 8585740288
Offset: 1

Views

Author

Reinhard Zumkeller, Nov 12 2003

Keywords

Comments

a(n) = Sum(A089818(n,k): 1<=k<=A000720(n)) = A000079(n)-A089819(n) = A089819(n)*A000225(A000720(n)).

Crossrefs

Programs

Formula

a(n) = 2^n - 2^(n-pi(n)) = the total number of subsets minus the number of subsets of the nonprime elements of {1,..,n}, where pi = A000720. - Greg Martin, May 13 2004

Extensions

More terms from Wesley Ivan Hurt, Sep 19 2014

A089821 Number of subsets of {1,.., n} containing exactly one prime.

Original entry on oeis.org

0, 2, 4, 8, 12, 24, 32, 64, 128, 256, 320, 640, 768, 1536, 3072, 6144, 7168, 14336, 16384, 32768, 65536, 131072, 147456, 294912, 589824, 1179648, 2359296, 4718592, 5242880, 10485760, 11534336, 23068672, 46137344, 92274688, 184549376, 369098752, 402653184
Offset: 1

Views

Author

Reinhard Zumkeller, Nov 12 2003

Keywords

Examples

			a(5)=12 subsets of {1,2,3,4,5} contain exactly one prime: {2}, {3}, {5}, {1,2}, {1,3}, {1,5}, {2,4}, {3,4}, {4,5}, {1,2,4}, {1,3,4} and {1,4,5}.
		

Crossrefs

Programs

  • Maple
    b:= proc(n, c) option remember; `if`(n=0, `if`(c=0, 1, 0),
         `if`(c<0, 0, b(n-1, c)+b(n-1, c-`if`(isprime(n), 1, 0))))
        end:
    a:= n-> b(n, 1):
    seq(a(n), n=1..42);  # Alois P. Heinz, Dec 19 2019
  • Mathematica
    b[n_, c_] := b[n, c] = If[n == 0, If[c == 0, 1, 0], If[c < 0, 0, b[n - 1, c] + b[n - 1, c - If[PrimeQ[n], 1, 0]]]];
    a[n_] := b[n, 1];
    Array[a, 42] (* Jean-François Alcover, Nov 07 2020, after Alois P. Heinz *)
  • PARI
    a(n) = primepi(n) * 2^(n-primepi(n)); \\ Michel Marcus, Nov 07 2020

Formula

a(n) = A000720(n)*A089819(n);
for n>1: a(n) = A089818(n,1).
a(n) = pi(n) * 2^(n-pi(n)), with pi = A000720.
Showing 1-4 of 4 results.