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.

A127542 Number of subsets of {1,2,3,...,n} whose sum is prime.

This page as a plain text file.
%I A127542 #25 Oct 22 2023 13:04:29
%S A127542 0,2,4,7,12,22,42,76,139,267,516,999,1951,3824,7486,14681,28797,56191,
%T A127542 108921,210746,410016,804971,1591352,3153835,6249154,12380967,
%U A127542 24553237,48731373,96622022,191012244,376293782,739671592,1454332766,2867413428,5678310305
%N A127542 Number of subsets of {1,2,3,...,n} whose sum is prime.
%H A127542 Charles R Greathouse IV, <a href="/A127542/b127542.txt">Table of n, a(n) for n = 1..1000</a> (first 100 terms from T. D. Noe)
%e A127542 The subsets of {1,2,3} that sum to a prime are {1,2}, {2}, {3}, {2,3}. Thus a(3)=4.
%p A127542 with(combinat): a:=proc(n) local ct, pn, j:ct:=0: pn:=powerset(n): for j from 1 to 2^n do if isprime(add(pn[j][i],i=1..nops(pn[j]))) =true then ct:=ct+1 else ct:=ct fi: od: end: seq(a(n),n=1..18);
%p A127542 # second Maple program:
%p A127542 b:= proc(n, s) option remember; `if`(n=0,
%p A127542      `if`(isprime(s), 1, 0), b(n-1, s)+b(n-1, s+n))
%p A127542     end:
%p A127542 a:= n-> b(n, 0):
%p A127542 seq(a(n), n=1..44);  # _Alois P. Heinz_, Oct 22 2023
%t A127542 g[n_] := Block[{p = Product[1 + z^i, {i, n}]},Sum[Boole[PrimeQ[k]]*Coefficient[p, z, k], {k, 0, n*(n + 1)/2}]];Array[g, 34] (* _Ray Chandler_, Mar 05 2007 *)
%o A127542 (Haskell)
%o A127542 import Data.List (subsequences)
%o A127542 a127542 = length . filter ((== 1) . a010051 . sum) .
%o A127542                           subsequences . enumFromTo 1
%o A127542 -- _Reinhard Zumkeller_, Feb 22 2012, Oct 27 2010
%o A127542 (PARI) a(n)=my(v=Vec(prod(i=1,n,x^i+1)),s);forprime(p=2,#v,s+=v[p]);s \\ _Charles R Greathouse IV_, Dec 19 2014
%o A127542 (PARI) first(n)=my(v=vector(n),P=1,s); for(k=1,n, P*=1+'x^n; s=0; forprime(p=2,k*(k+1)/2,s+=polcoeff(P,p)); v[k]=s); v \\ _Charles R Greathouse IV_, Dec 19 2014
%Y A127542 Cf. A053632, A126024, A181522, A010051.
%Y A127542 Row sums of A282516.
%K A127542 nonn
%O A127542 1,2
%A A127542 _Emeric Deutsch_, Mar 03 2007
%E A127542 Extended by _Ray Chandler_, Mar 05 2007