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
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.
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
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}.
-
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
-
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 *)
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
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
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}.
-
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
-
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 *)
-
a(n) = primepi(n) * 2^(n-primepi(n)); \\ Michel Marcus, Nov 07 2020
Showing 1-4 of 4 results.
Comments