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.

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

This page as a plain text file.
%I A089822 #26 May 30 2020 09:20:57
%S A089822 0,0,2,4,12,24,48,96,192,384,640,1280,1920,3840,7680,15360,21504,
%T A089822 43008,57344,114688,229376,458752,589824,1179648,2359296,4718592,
%U A089822 9437184,18874368,23592960,47185920,57671680,115343360,230686720
%N A089822 Number of subsets of {1,.., n} containing exactly two primes.
%H A089822 Robert Israel, <a href="/A089822/b089822.txt">Table of n, a(n) for n = 1..3830</a>
%F A089822 a(n) = (pi(n)*(pi(n)-1)*2^(n-pi(n)))/2, with pi = A000720.
%F A089822 a(n) = A000217(A000720(n)-1)*A089819(n);
%F A089822 for n>2: a(n) = A089818(n,2).
%e A089822 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}.
%p A089822 N:= 100: # for a(1)..a(N)
%p A089822 V:= Vector(N):
%p A089822 p:= 1: n:= 1: pi:= 0:
%p A089822 while n <= N do
%p A089822   p:= nextprime(p);
%p A089822   for n from n to min(N,p-1) do
%p A089822     V[n]:= pi*(pi-1)*2^(n-pi)/2;
%p A089822   od;
%p A089822   pi:= pi+1;
%p A089822   n:= p;
%p A089822 od:
%p A089822 convert(V,list); # _Robert Israel_, Jul 14 2019
%p A089822 # second Maple program:
%p A089822 b:= proc(n, c) option remember; `if`(n=0, `if`(c=0, 1, 0),
%p A089822      `if`(c<0, 0, b(n-1, c)+b(n-1, c-`if`(isprime(n), 1, 0))))
%p A089822     end:
%p A089822 a:= n-> b(n, 2):
%p A089822 seq(a(n), n=1..42);  # _Alois P. Heinz_, Dec 19 2019
%t A089822 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]]]];
%t A089822 a[n_] := b[n, 2];
%t A089822 Array[a, 42] (* _Jean-François Alcover_, May 30 2020, after _Alois P. Heinz_ *)
%Y A089822 Cf. A000217, A000720, A089818, A089819, A089821.
%K A089822 nonn
%O A089822 1,3
%A A089822 _Reinhard Zumkeller_, Nov 12 2003