login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A378844
Number of subsets of {1..n} whose arithmetic and harmonic means are both integers.
1
1, 2, 3, 4, 5, 8, 9, 10, 11, 13, 14, 18, 19, 21, 27, 28, 29, 48, 49, 71, 75, 78, 79, 103, 104, 105, 106, 203, 204, 325, 326, 327, 530, 533, 795, 1198, 1199, 1204
OFFSET
1,2
FORMULA
a(p^k) = a(p^k-1)+1 for p prime (see A339453). - Chai Wah Wu, Dec 12 2024
EXAMPLE
a(6) = 8 subsets: {1}, {2}, {3}, {4}, {5}, {6}, {2, 6} and {1, 2, 3, 6}.
MATHEMATICA
a[n_] := Count[Subsets[Range[n]], _?(# != {} && IntegerQ[Mean[#]] && IntegerQ[HarmonicMean[#]] &)]; Array[a, 20] (* Amiram Eldar, Dec 10 2024 *)
PROG
(PARI) a(n) = {my(c = 0); forsubset(n, s, if(#s && !(vecsum(Vec(s)) % #s) && denominator(#s/sum(i=1, #s, 1/s[i])) == 1, c++)); c; } \\ Amiram Eldar, Dec 10 2024
(Python)
from math import lcm
from itertools import combinations
def A378844(n):
m = lcm(*range(2, n+1))
return sum(1 for l in range(1, n+1) for c in combinations(range(1, n+1), l) if not (sum(c)%l or l*m%sum(m//d for d in c))) # Chai Wah Wu, Dec 12 2024
CROSSREFS
KEYWORD
nonn,more
AUTHOR
Ilya Gutkovskiy, Dec 09 2024
EXTENSIONS
a(25)-a(29) from Amiram Eldar, Dec 10 2024
a(30)-a(33) from Chai Wah Wu, Dec 12 2024
a(34)-a(38) from Chai Wah Wu, Dec 13 2024
STATUS
approved