[go: up one dir, main page]

login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A127542 Number of subsets of {1,2,3,...,n} whose sum is prime. 11
0, 2, 4, 7, 12, 22, 42, 76, 139, 267, 516, 999, 1951, 3824, 7486, 14681, 28797, 56191, 108921, 210746, 410016, 804971, 1591352, 3153835, 6249154, 12380967, 24553237, 48731373, 96622022, 191012244, 376293782, 739671592, 1454332766, 2867413428, 5678310305 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..1000 (first 100 terms from T. D. Noe)
EXAMPLE
The subsets of {1,2,3} that sum to a prime are {1,2}, {2}, {3}, {2,3}. Thus a(3)=4.
MAPLE
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);
# second Maple program:
b:= proc(n, s) option remember; `if`(n=0,
`if`(isprime(s), 1, 0), b(n-1, s)+b(n-1, s+n))
end:
a:= n-> b(n, 0):
seq(a(n), n=1..44); # Alois P. Heinz, Oct 22 2023
MATHEMATICA
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 *)
PROG
(Haskell)
import Data.List (subsequences)
a127542 = length . filter ((== 1) . a010051 . sum) .
subsequences . enumFromTo 1
-- Reinhard Zumkeller, Feb 22 2012, Oct 27 2010
(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
(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
CROSSREFS
Row sums of A282516.
Sequence in context: A268306 A018179 A190165 * A023432 A072641 A280352
KEYWORD
nonn
AUTHOR
Emeric Deutsch, Mar 03 2007
EXTENSIONS
Extended by Ray Chandler, Mar 05 2007
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 30 00:57 EDT 2024. Contains 375520 sequences. (Running on oeis4.)