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.
%I A339485 #40 Feb 16 2025 08:34:01 %S A339485 1,2,3,6,9,12,17,30,51,88,149,264,439,746,1261,2234,4211,7996,14899, %T A339485 28048,54037,106442,208625,398588,735365,1331590,2421573,4481896, %U A339485 8504953,16497150,32595915,64614636,127968263,252470776,495388085,962475122,1847742473,3504948056 %N A339485 Number of subsets of the first n primes whose elements have a prime average. %H A339485 Alois P. Heinz, <a href="/A339485/b339485.txt">Table of n, a(n) for n = 1..150</a> %H A339485 Eric W. Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/ArithmeticMean.html">Arithmetic Mean</a> %e A339485 a(5) = 9 subsets: {2}, {3}, {5}, {7}, {11}, {3, 7}, {3, 11}, {3, 5, 7} and {3, 7, 11}. %p A339485 b:= proc(n, s, c) option remember; `if`(n=0, %p A339485 `if`(c>0 and denom(s)=1 and isprime(s), 1, 0), %p A339485 b(n-1, s, c)+b(n-1, (s*c+ithprime(n))/(c+1), c+1)) %p A339485 end: %p A339485 a:= n-> b(n, 0$2): %p A339485 seq(a(n), n=1..40); # _Alois P. Heinz_, Dec 08 2020 %t A339485 b[n_, s_, c_] := b[n, s, c] = If[n == 0, %t A339485 If[c > 0 && Denominator[s] == 1 && PrimeQ[s], 1, 0], %t A339485 b[n-1, s, c] + b[n-1, (s*c + Prime[n])/(c+1), c+1]]; %t A339485 a[n_] := b[n, 0, 0]; %t A339485 Array[a, 40] (* _Jean-François Alcover_, Jul 09 2021, after _Alois P. Heinz_ *) %o A339485 (Python) %o A339485 from sympy import prime, isprime %o A339485 from itertools import chain, combinations %o A339485 def powerset(s): # skip empty set and singletons %o A339485 return chain.from_iterable(combinations(s, r) for r in range(2,len(s)+1)) %o A339485 def a(n): %o A339485 out = n # count all singletons %o A339485 for s in powerset([prime(i) for i in range(1, n+1)]): %o A339485 ss = sum(s) %o A339485 if ss%len(s) == 0: %o A339485 if isprime(ss//len(s)): out += 1 %o A339485 return out %o A339485 print([a(n) for n in range(1, 21)]) # _Michael S. Branicky_, Dec 06 2020 %o A339485 (Python) %o A339485 from itertools import combinations %o A339485 from sympy import prime %o A339485 def A339485(n): %o A339485 c, primeset2 = n, set(prime(i) for i in range(1,n)) %o A339485 primeset = primeset2 | {prime(n)} %o A339485 for l in range(2,n+1): %o A339485 for d in combinations(primeset,l): %o A339485 a, b = divmod(sum(d),l) %o A339485 if b == 0 and a in primeset2: %o A339485 c += 1 %o A339485 return c # _Chai Wah Wu_, Dec 07 2020 %o A339485 (Python) %o A339485 from functools import lru_cache %o A339485 from sympy import sieve, isprime %o A339485 @lru_cache(maxsize=None) %o A339485 def b(n, s, c): %o A339485 if n == 0: return int(c and s%c == 0 and isprime(s//c)) %o A339485 return b(n-1, s, c) + b(n-1, s+sieve[n], c+1) %o A339485 a = lambda n: b(n, 0, 0) %o A339485 print([a(n) for n in range(1, 41)]) # _Michael S. Branicky_, Oct 06 2022 %Y A339485 Cf. A000040, A051293, A071810, A127542, A309160. %K A339485 nonn %O A339485 1,2 %A A339485 _Ilya Gutkovskiy_, Dec 06 2020 %E A339485 a(10)-a(30) from _Michael S. Branicky_, Dec 06 2020 %E A339485 a(31)-a(34) from _Chai Wah Wu_, Dec 07 2020 %E A339485 a(35)-a(36) from _Michael S. Branicky_, Dec 08 2020 %E A339485 a(37)-a(38) from _Chai Wah Wu_, Dec 08 2020