Number of $n$-element subsets of ${1, 2, dotsc, 3n}$ with sum divisible by $n$












3












$begingroup$



Is there any recurrence relations/formula/algorithm to count the number of $n$-element subsets of the set ${1, 2, dotsc, 3n}$ with sum divisible by $n$? How about replacing $3n$ with $kn$?




I currently only know that if $k=2$, then the number of $n$-element subsets divisible by $n$ is



$$
frac{(-1)^n}{n}sum_{d mid n} (-1)^dphi({nover d})binom{2d}{d}
$$

from http://oeis.org/A169888, but a similar search for $k=3$ doesn't return any results.
Is there any similar formula for $k geq 3$?



Thanks.



Some bruteforced values for $k=3$:
$$
begin{array}{c|ccccccccc}
n
& 1
& 2
& 3
& 4
& 5
& 6
& 7
& 8
& 9
\
hline
text{$n$-element subsets}
& 3
& 6
& 30
& 126
& 603
& 3084
& 16614
& 91998
& 520779
\
end{array}
$$










share|cite|improve this question











$endgroup$












  • $begingroup$
    Excuse my ignorance, but is there ''easy'' way to prove the formula in OP (with use of the Burnside or PET of course)? @Marko Riedel
    $endgroup$
    – greedoid
    Jan 1 at 16:03


















3












$begingroup$



Is there any recurrence relations/formula/algorithm to count the number of $n$-element subsets of the set ${1, 2, dotsc, 3n}$ with sum divisible by $n$? How about replacing $3n$ with $kn$?




I currently only know that if $k=2$, then the number of $n$-element subsets divisible by $n$ is



$$
frac{(-1)^n}{n}sum_{d mid n} (-1)^dphi({nover d})binom{2d}{d}
$$

from http://oeis.org/A169888, but a similar search for $k=3$ doesn't return any results.
Is there any similar formula for $k geq 3$?



Thanks.



Some bruteforced values for $k=3$:
$$
begin{array}{c|ccccccccc}
n
& 1
& 2
& 3
& 4
& 5
& 6
& 7
& 8
& 9
\
hline
text{$n$-element subsets}
& 3
& 6
& 30
& 126
& 603
& 3084
& 16614
& 91998
& 520779
\
end{array}
$$










share|cite|improve this question











$endgroup$












  • $begingroup$
    Excuse my ignorance, but is there ''easy'' way to prove the formula in OP (with use of the Burnside or PET of course)? @Marko Riedel
    $endgroup$
    – greedoid
    Jan 1 at 16:03
















3












3








3


1



$begingroup$



Is there any recurrence relations/formula/algorithm to count the number of $n$-element subsets of the set ${1, 2, dotsc, 3n}$ with sum divisible by $n$? How about replacing $3n$ with $kn$?




I currently only know that if $k=2$, then the number of $n$-element subsets divisible by $n$ is



$$
frac{(-1)^n}{n}sum_{d mid n} (-1)^dphi({nover d})binom{2d}{d}
$$

from http://oeis.org/A169888, but a similar search for $k=3$ doesn't return any results.
Is there any similar formula for $k geq 3$?



Thanks.



Some bruteforced values for $k=3$:
$$
begin{array}{c|ccccccccc}
n
& 1
& 2
& 3
& 4
& 5
& 6
& 7
& 8
& 9
\
hline
text{$n$-element subsets}
& 3
& 6
& 30
& 126
& 603
& 3084
& 16614
& 91998
& 520779
\
end{array}
$$










share|cite|improve this question











$endgroup$





Is there any recurrence relations/formula/algorithm to count the number of $n$-element subsets of the set ${1, 2, dotsc, 3n}$ with sum divisible by $n$? How about replacing $3n$ with $kn$?




I currently only know that if $k=2$, then the number of $n$-element subsets divisible by $n$ is



$$
frac{(-1)^n}{n}sum_{d mid n} (-1)^dphi({nover d})binom{2d}{d}
$$

from http://oeis.org/A169888, but a similar search for $k=3$ doesn't return any results.
Is there any similar formula for $k geq 3$?



Thanks.



Some bruteforced values for $k=3$:
$$
begin{array}{c|ccccccccc}
n
& 1
& 2
& 3
& 4
& 5
& 6
& 7
& 8
& 9
\
hline
text{$n$-element subsets}
& 3
& 6
& 30
& 126
& 603
& 3084
& 16614
& 91998
& 520779
\
end{array}
$$







elementary-set-theory algorithms divisibility polya-counting-theory






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Jan 1 at 16:24









greedoid

45k1157112




45k1157112










asked Aug 26 '18 at 2:34









Gareth MaGareth Ma

526215




526215












  • $begingroup$
    Excuse my ignorance, but is there ''easy'' way to prove the formula in OP (with use of the Burnside or PET of course)? @Marko Riedel
    $endgroup$
    – greedoid
    Jan 1 at 16:03




















  • $begingroup$
    Excuse my ignorance, but is there ''easy'' way to prove the formula in OP (with use of the Burnside or PET of course)? @Marko Riedel
    $endgroup$
    – greedoid
    Jan 1 at 16:03


















$begingroup$
Excuse my ignorance, but is there ''easy'' way to prove the formula in OP (with use of the Burnside or PET of course)? @Marko Riedel
$endgroup$
– greedoid
Jan 1 at 16:03






$begingroup$
Excuse my ignorance, but is there ''easy'' way to prove the formula in OP (with use of the Burnside or PET of course)? @Marko Riedel
$endgroup$
– greedoid
Jan 1 at 16:03












1 Answer
1






active

oldest

votes


















6












$begingroup$

We ask about the probability that a set of size $n$ drawn from $[kn]$
has sum divisible by $n$. The exponential formula tells us that the
cycle index $Z(P_n)$ of the unlabeled set operator



$$deftextsc#1{dosc#1csod}
defdosc#1#2csod{{rm #1{small #2}}}textsc{SET}$$



on $n$ slots has OGF



$$Z(P_n) = [w^n]
expleft(sum_{lge 1} (-1)^{l-1} a_l frac{w^l}{l}right).$$



The desired probability is given by



$${knchoose n}^{-1} frac{1}{n}
sum_{p=0}^{n-1}
left. Z
left(P_n; sum_{q=1}^{kn} z^qright)right|
_{z=exp(2pi ip/n)}.$$



This is



$${knchoose n}^{-1} frac{1}{n}
sum_{p=0}^{n-1} left. [w^n]
exp
left(sum_{lge 1} (-1)^{l-1} left(sum_{q=1}^{kn} z^{ql}right)
frac{w^l}{l}right)right|_{z=exp(2pi ip/n)}.$$



Evaluating the contribution for $p=0$ first we get



$${knchoose n}^{-1} frac{1}{n}
[w^n] expleft(sum_{lge 1} (-1)^{l-1} kn
frac{w^l}{l}right)
\ = {knchoose n}^{-1} frac{1}{n}
[w^n] expleft(kn log(1+w)right)
\ = {knchoose n}^{-1} frac{1}{n}
[w^n] (1+w)^{kn}
= {knchoose n}^{-1} frac{1}{n} {knchoose n}
= frac{1}{n}.$$



It remains to evaluate the contribution from $1le ple n-1.$ Now for
these $p$ if $l$ is a multiple of $m = n/gcd(p, n)$ we have



$$sum_{q=1}^{kn} exp(2pi ip/n)^{ql} = kn.$$



We get zero otherwise. This yields for the remaining terms without the
scalar in front



$$sum_{p=1}^{n-1} [w^n]
expleft(sum_{lge 1} (-1)^{ml-1} kn
frac{w^{ml}}{ml} right)
= sum_{p=1}^{n-1} [w^n]
expleft(-frac{kn}{m} sum_{lge 1}
frac{(-w)^{ml}}{l} right)
\ = sum_{p=1}^{n-1} [w^n]
expleft(-frac{kn}{m}logfrac{1}{1-(-w)^m}right)
= sum_{p=1}^{n-1} [w^n] (1-(-w)^{n/gcd(p, n)})^{kgcd(p, n)}
\ = sum_{p=1}^{n-1} [w^n] (1+(-1)^{1+n/gcd(p, n)}
w^{n/gcd(p, n)})^{kgcd(p, n)}.$$



This is



$$sum_{p=1}^{n-1} {kgcd(p,n) choose gcd(p,n)}
(-1)^{(1+n/gcd(p, n)) gcd(p,n)}.$$



Putting it all together we thus obtain



$$bbox[5px,border:2px solid #00A000]{
frac{1}{n} + (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{p=1}^{n-1} {kgcd(p,n) choose gcd(p,n)}
(-1)^{gcd(p,n)}.}$$



While this formula will produce results it may perhaps be simplified.
Write



$$frac{1}{n} =
(-1)^n {knchoose n}^{-1} frac{1}{n}
{kgcd(n,n)choose gcd(n,n)} (-1)^{gcd(n,n)}$$



to get



$$(-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{p=1}^{n}
{kgcd(p, n)choose gcd(p,n)}
(-1)^{gcd(p,n)}
\ = (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} sum_{gcd(p,n)=d}
{kdchoose d}
(-1)^{d}
\ = (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} {kdchoose d}
(-1)^{d} sum_{gcd(q,n/d)=1} 1.$$



We find the alternate closed form



$$bbox[5px,border:2px solid #00A000]{
(-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} {kdchoose d}
(-1)^d varphi(n/d).}$$



These two formulae were verified by simple enumeration for $1le nle
7$ and $1le kle 6,$ see below.




with(combinat);
with(numtheory);

ENUM :=
proc(k, n)
option remember;
local recurse, admit, total;

admit := 0; total := 0;

recurse :=
proc(pos, selcount, sumsofar)
if selcount = n then
if sumsofar mod n = 0 then
admit := admit + 1;
fi;

total := total + 1;

return;
fi;

if pos > k*n then return fi;

recurse(pos+1, selcount, sumsofar);
recurse(pos+1, selcount + 1,
sumsofar + pos);
end;

recurse(1, 0, 0);
admit/total;
end;

X := (k, n) ->
1/n+(-1)^n*binomial(k*n,n)^(-1)*1/n
* add(binomial(k*gcd(p,n),gcd(p,n))*(-1)^gcd(p,n),
p=1..n-1);

XX := (k, n) ->
(-1)^n*binomial(k*n,n)^(-1)*1/n
* add(binomial(k*d,d)*(-1)^d*phi(n/d),
d in divisors(n));



Remark. This computation is based on material from this MSE
link.






share|cite|improve this answer











$endgroup$













  • $begingroup$
    This proof looks nice! Unfornately it is quite above my level so I need time to understand it. Nice work!
    $endgroup$
    – Gareth Ma
    Aug 26 '18 at 23:37











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2894653%2fnumber-of-n-element-subsets-of-1-2-dotsc-3n-with-sum-divisible-by-n%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









6












$begingroup$

We ask about the probability that a set of size $n$ drawn from $[kn]$
has sum divisible by $n$. The exponential formula tells us that the
cycle index $Z(P_n)$ of the unlabeled set operator



$$deftextsc#1{dosc#1csod}
defdosc#1#2csod{{rm #1{small #2}}}textsc{SET}$$



on $n$ slots has OGF



$$Z(P_n) = [w^n]
expleft(sum_{lge 1} (-1)^{l-1} a_l frac{w^l}{l}right).$$



The desired probability is given by



$${knchoose n}^{-1} frac{1}{n}
sum_{p=0}^{n-1}
left. Z
left(P_n; sum_{q=1}^{kn} z^qright)right|
_{z=exp(2pi ip/n)}.$$



This is



$${knchoose n}^{-1} frac{1}{n}
sum_{p=0}^{n-1} left. [w^n]
exp
left(sum_{lge 1} (-1)^{l-1} left(sum_{q=1}^{kn} z^{ql}right)
frac{w^l}{l}right)right|_{z=exp(2pi ip/n)}.$$



Evaluating the contribution for $p=0$ first we get



$${knchoose n}^{-1} frac{1}{n}
[w^n] expleft(sum_{lge 1} (-1)^{l-1} kn
frac{w^l}{l}right)
\ = {knchoose n}^{-1} frac{1}{n}
[w^n] expleft(kn log(1+w)right)
\ = {knchoose n}^{-1} frac{1}{n}
[w^n] (1+w)^{kn}
= {knchoose n}^{-1} frac{1}{n} {knchoose n}
= frac{1}{n}.$$



It remains to evaluate the contribution from $1le ple n-1.$ Now for
these $p$ if $l$ is a multiple of $m = n/gcd(p, n)$ we have



$$sum_{q=1}^{kn} exp(2pi ip/n)^{ql} = kn.$$



We get zero otherwise. This yields for the remaining terms without the
scalar in front



$$sum_{p=1}^{n-1} [w^n]
expleft(sum_{lge 1} (-1)^{ml-1} kn
frac{w^{ml}}{ml} right)
= sum_{p=1}^{n-1} [w^n]
expleft(-frac{kn}{m} sum_{lge 1}
frac{(-w)^{ml}}{l} right)
\ = sum_{p=1}^{n-1} [w^n]
expleft(-frac{kn}{m}logfrac{1}{1-(-w)^m}right)
= sum_{p=1}^{n-1} [w^n] (1-(-w)^{n/gcd(p, n)})^{kgcd(p, n)}
\ = sum_{p=1}^{n-1} [w^n] (1+(-1)^{1+n/gcd(p, n)}
w^{n/gcd(p, n)})^{kgcd(p, n)}.$$



This is



$$sum_{p=1}^{n-1} {kgcd(p,n) choose gcd(p,n)}
(-1)^{(1+n/gcd(p, n)) gcd(p,n)}.$$



Putting it all together we thus obtain



$$bbox[5px,border:2px solid #00A000]{
frac{1}{n} + (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{p=1}^{n-1} {kgcd(p,n) choose gcd(p,n)}
(-1)^{gcd(p,n)}.}$$



While this formula will produce results it may perhaps be simplified.
Write



$$frac{1}{n} =
(-1)^n {knchoose n}^{-1} frac{1}{n}
{kgcd(n,n)choose gcd(n,n)} (-1)^{gcd(n,n)}$$



to get



$$(-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{p=1}^{n}
{kgcd(p, n)choose gcd(p,n)}
(-1)^{gcd(p,n)}
\ = (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} sum_{gcd(p,n)=d}
{kdchoose d}
(-1)^{d}
\ = (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} {kdchoose d}
(-1)^{d} sum_{gcd(q,n/d)=1} 1.$$



We find the alternate closed form



$$bbox[5px,border:2px solid #00A000]{
(-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} {kdchoose d}
(-1)^d varphi(n/d).}$$



These two formulae were verified by simple enumeration for $1le nle
7$ and $1le kle 6,$ see below.




with(combinat);
with(numtheory);

ENUM :=
proc(k, n)
option remember;
local recurse, admit, total;

admit := 0; total := 0;

recurse :=
proc(pos, selcount, sumsofar)
if selcount = n then
if sumsofar mod n = 0 then
admit := admit + 1;
fi;

total := total + 1;

return;
fi;

if pos > k*n then return fi;

recurse(pos+1, selcount, sumsofar);
recurse(pos+1, selcount + 1,
sumsofar + pos);
end;

recurse(1, 0, 0);
admit/total;
end;

X := (k, n) ->
1/n+(-1)^n*binomial(k*n,n)^(-1)*1/n
* add(binomial(k*gcd(p,n),gcd(p,n))*(-1)^gcd(p,n),
p=1..n-1);

XX := (k, n) ->
(-1)^n*binomial(k*n,n)^(-1)*1/n
* add(binomial(k*d,d)*(-1)^d*phi(n/d),
d in divisors(n));



Remark. This computation is based on material from this MSE
link.






share|cite|improve this answer











$endgroup$













  • $begingroup$
    This proof looks nice! Unfornately it is quite above my level so I need time to understand it. Nice work!
    $endgroup$
    – Gareth Ma
    Aug 26 '18 at 23:37
















6












$begingroup$

We ask about the probability that a set of size $n$ drawn from $[kn]$
has sum divisible by $n$. The exponential formula tells us that the
cycle index $Z(P_n)$ of the unlabeled set operator



$$deftextsc#1{dosc#1csod}
defdosc#1#2csod{{rm #1{small #2}}}textsc{SET}$$



on $n$ slots has OGF



$$Z(P_n) = [w^n]
expleft(sum_{lge 1} (-1)^{l-1} a_l frac{w^l}{l}right).$$



The desired probability is given by



$${knchoose n}^{-1} frac{1}{n}
sum_{p=0}^{n-1}
left. Z
left(P_n; sum_{q=1}^{kn} z^qright)right|
_{z=exp(2pi ip/n)}.$$



This is



$${knchoose n}^{-1} frac{1}{n}
sum_{p=0}^{n-1} left. [w^n]
exp
left(sum_{lge 1} (-1)^{l-1} left(sum_{q=1}^{kn} z^{ql}right)
frac{w^l}{l}right)right|_{z=exp(2pi ip/n)}.$$



Evaluating the contribution for $p=0$ first we get



$${knchoose n}^{-1} frac{1}{n}
[w^n] expleft(sum_{lge 1} (-1)^{l-1} kn
frac{w^l}{l}right)
\ = {knchoose n}^{-1} frac{1}{n}
[w^n] expleft(kn log(1+w)right)
\ = {knchoose n}^{-1} frac{1}{n}
[w^n] (1+w)^{kn}
= {knchoose n}^{-1} frac{1}{n} {knchoose n}
= frac{1}{n}.$$



It remains to evaluate the contribution from $1le ple n-1.$ Now for
these $p$ if $l$ is a multiple of $m = n/gcd(p, n)$ we have



$$sum_{q=1}^{kn} exp(2pi ip/n)^{ql} = kn.$$



We get zero otherwise. This yields for the remaining terms without the
scalar in front



$$sum_{p=1}^{n-1} [w^n]
expleft(sum_{lge 1} (-1)^{ml-1} kn
frac{w^{ml}}{ml} right)
= sum_{p=1}^{n-1} [w^n]
expleft(-frac{kn}{m} sum_{lge 1}
frac{(-w)^{ml}}{l} right)
\ = sum_{p=1}^{n-1} [w^n]
expleft(-frac{kn}{m}logfrac{1}{1-(-w)^m}right)
= sum_{p=1}^{n-1} [w^n] (1-(-w)^{n/gcd(p, n)})^{kgcd(p, n)}
\ = sum_{p=1}^{n-1} [w^n] (1+(-1)^{1+n/gcd(p, n)}
w^{n/gcd(p, n)})^{kgcd(p, n)}.$$



This is



$$sum_{p=1}^{n-1} {kgcd(p,n) choose gcd(p,n)}
(-1)^{(1+n/gcd(p, n)) gcd(p,n)}.$$



Putting it all together we thus obtain



$$bbox[5px,border:2px solid #00A000]{
frac{1}{n} + (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{p=1}^{n-1} {kgcd(p,n) choose gcd(p,n)}
(-1)^{gcd(p,n)}.}$$



While this formula will produce results it may perhaps be simplified.
Write



$$frac{1}{n} =
(-1)^n {knchoose n}^{-1} frac{1}{n}
{kgcd(n,n)choose gcd(n,n)} (-1)^{gcd(n,n)}$$



to get



$$(-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{p=1}^{n}
{kgcd(p, n)choose gcd(p,n)}
(-1)^{gcd(p,n)}
\ = (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} sum_{gcd(p,n)=d}
{kdchoose d}
(-1)^{d}
\ = (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} {kdchoose d}
(-1)^{d} sum_{gcd(q,n/d)=1} 1.$$



We find the alternate closed form



$$bbox[5px,border:2px solid #00A000]{
(-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} {kdchoose d}
(-1)^d varphi(n/d).}$$



These two formulae were verified by simple enumeration for $1le nle
7$ and $1le kle 6,$ see below.




with(combinat);
with(numtheory);

ENUM :=
proc(k, n)
option remember;
local recurse, admit, total;

admit := 0; total := 0;

recurse :=
proc(pos, selcount, sumsofar)
if selcount = n then
if sumsofar mod n = 0 then
admit := admit + 1;
fi;

total := total + 1;

return;
fi;

if pos > k*n then return fi;

recurse(pos+1, selcount, sumsofar);
recurse(pos+1, selcount + 1,
sumsofar + pos);
end;

recurse(1, 0, 0);
admit/total;
end;

X := (k, n) ->
1/n+(-1)^n*binomial(k*n,n)^(-1)*1/n
* add(binomial(k*gcd(p,n),gcd(p,n))*(-1)^gcd(p,n),
p=1..n-1);

XX := (k, n) ->
(-1)^n*binomial(k*n,n)^(-1)*1/n
* add(binomial(k*d,d)*(-1)^d*phi(n/d),
d in divisors(n));



Remark. This computation is based on material from this MSE
link.






share|cite|improve this answer











$endgroup$













  • $begingroup$
    This proof looks nice! Unfornately it is quite above my level so I need time to understand it. Nice work!
    $endgroup$
    – Gareth Ma
    Aug 26 '18 at 23:37














6












6








6





$begingroup$

We ask about the probability that a set of size $n$ drawn from $[kn]$
has sum divisible by $n$. The exponential formula tells us that the
cycle index $Z(P_n)$ of the unlabeled set operator



$$deftextsc#1{dosc#1csod}
defdosc#1#2csod{{rm #1{small #2}}}textsc{SET}$$



on $n$ slots has OGF



$$Z(P_n) = [w^n]
expleft(sum_{lge 1} (-1)^{l-1} a_l frac{w^l}{l}right).$$



The desired probability is given by



$${knchoose n}^{-1} frac{1}{n}
sum_{p=0}^{n-1}
left. Z
left(P_n; sum_{q=1}^{kn} z^qright)right|
_{z=exp(2pi ip/n)}.$$



This is



$${knchoose n}^{-1} frac{1}{n}
sum_{p=0}^{n-1} left. [w^n]
exp
left(sum_{lge 1} (-1)^{l-1} left(sum_{q=1}^{kn} z^{ql}right)
frac{w^l}{l}right)right|_{z=exp(2pi ip/n)}.$$



Evaluating the contribution for $p=0$ first we get



$${knchoose n}^{-1} frac{1}{n}
[w^n] expleft(sum_{lge 1} (-1)^{l-1} kn
frac{w^l}{l}right)
\ = {knchoose n}^{-1} frac{1}{n}
[w^n] expleft(kn log(1+w)right)
\ = {knchoose n}^{-1} frac{1}{n}
[w^n] (1+w)^{kn}
= {knchoose n}^{-1} frac{1}{n} {knchoose n}
= frac{1}{n}.$$



It remains to evaluate the contribution from $1le ple n-1.$ Now for
these $p$ if $l$ is a multiple of $m = n/gcd(p, n)$ we have



$$sum_{q=1}^{kn} exp(2pi ip/n)^{ql} = kn.$$



We get zero otherwise. This yields for the remaining terms without the
scalar in front



$$sum_{p=1}^{n-1} [w^n]
expleft(sum_{lge 1} (-1)^{ml-1} kn
frac{w^{ml}}{ml} right)
= sum_{p=1}^{n-1} [w^n]
expleft(-frac{kn}{m} sum_{lge 1}
frac{(-w)^{ml}}{l} right)
\ = sum_{p=1}^{n-1} [w^n]
expleft(-frac{kn}{m}logfrac{1}{1-(-w)^m}right)
= sum_{p=1}^{n-1} [w^n] (1-(-w)^{n/gcd(p, n)})^{kgcd(p, n)}
\ = sum_{p=1}^{n-1} [w^n] (1+(-1)^{1+n/gcd(p, n)}
w^{n/gcd(p, n)})^{kgcd(p, n)}.$$



This is



$$sum_{p=1}^{n-1} {kgcd(p,n) choose gcd(p,n)}
(-1)^{(1+n/gcd(p, n)) gcd(p,n)}.$$



Putting it all together we thus obtain



$$bbox[5px,border:2px solid #00A000]{
frac{1}{n} + (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{p=1}^{n-1} {kgcd(p,n) choose gcd(p,n)}
(-1)^{gcd(p,n)}.}$$



While this formula will produce results it may perhaps be simplified.
Write



$$frac{1}{n} =
(-1)^n {knchoose n}^{-1} frac{1}{n}
{kgcd(n,n)choose gcd(n,n)} (-1)^{gcd(n,n)}$$



to get



$$(-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{p=1}^{n}
{kgcd(p, n)choose gcd(p,n)}
(-1)^{gcd(p,n)}
\ = (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} sum_{gcd(p,n)=d}
{kdchoose d}
(-1)^{d}
\ = (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} {kdchoose d}
(-1)^{d} sum_{gcd(q,n/d)=1} 1.$$



We find the alternate closed form



$$bbox[5px,border:2px solid #00A000]{
(-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} {kdchoose d}
(-1)^d varphi(n/d).}$$



These two formulae were verified by simple enumeration for $1le nle
7$ and $1le kle 6,$ see below.




with(combinat);
with(numtheory);

ENUM :=
proc(k, n)
option remember;
local recurse, admit, total;

admit := 0; total := 0;

recurse :=
proc(pos, selcount, sumsofar)
if selcount = n then
if sumsofar mod n = 0 then
admit := admit + 1;
fi;

total := total + 1;

return;
fi;

if pos > k*n then return fi;

recurse(pos+1, selcount, sumsofar);
recurse(pos+1, selcount + 1,
sumsofar + pos);
end;

recurse(1, 0, 0);
admit/total;
end;

X := (k, n) ->
1/n+(-1)^n*binomial(k*n,n)^(-1)*1/n
* add(binomial(k*gcd(p,n),gcd(p,n))*(-1)^gcd(p,n),
p=1..n-1);

XX := (k, n) ->
(-1)^n*binomial(k*n,n)^(-1)*1/n
* add(binomial(k*d,d)*(-1)^d*phi(n/d),
d in divisors(n));



Remark. This computation is based on material from this MSE
link.






share|cite|improve this answer











$endgroup$



We ask about the probability that a set of size $n$ drawn from $[kn]$
has sum divisible by $n$. The exponential formula tells us that the
cycle index $Z(P_n)$ of the unlabeled set operator



$$deftextsc#1{dosc#1csod}
defdosc#1#2csod{{rm #1{small #2}}}textsc{SET}$$



on $n$ slots has OGF



$$Z(P_n) = [w^n]
expleft(sum_{lge 1} (-1)^{l-1} a_l frac{w^l}{l}right).$$



The desired probability is given by



$${knchoose n}^{-1} frac{1}{n}
sum_{p=0}^{n-1}
left. Z
left(P_n; sum_{q=1}^{kn} z^qright)right|
_{z=exp(2pi ip/n)}.$$



This is



$${knchoose n}^{-1} frac{1}{n}
sum_{p=0}^{n-1} left. [w^n]
exp
left(sum_{lge 1} (-1)^{l-1} left(sum_{q=1}^{kn} z^{ql}right)
frac{w^l}{l}right)right|_{z=exp(2pi ip/n)}.$$



Evaluating the contribution for $p=0$ first we get



$${knchoose n}^{-1} frac{1}{n}
[w^n] expleft(sum_{lge 1} (-1)^{l-1} kn
frac{w^l}{l}right)
\ = {knchoose n}^{-1} frac{1}{n}
[w^n] expleft(kn log(1+w)right)
\ = {knchoose n}^{-1} frac{1}{n}
[w^n] (1+w)^{kn}
= {knchoose n}^{-1} frac{1}{n} {knchoose n}
= frac{1}{n}.$$



It remains to evaluate the contribution from $1le ple n-1.$ Now for
these $p$ if $l$ is a multiple of $m = n/gcd(p, n)$ we have



$$sum_{q=1}^{kn} exp(2pi ip/n)^{ql} = kn.$$



We get zero otherwise. This yields for the remaining terms without the
scalar in front



$$sum_{p=1}^{n-1} [w^n]
expleft(sum_{lge 1} (-1)^{ml-1} kn
frac{w^{ml}}{ml} right)
= sum_{p=1}^{n-1} [w^n]
expleft(-frac{kn}{m} sum_{lge 1}
frac{(-w)^{ml}}{l} right)
\ = sum_{p=1}^{n-1} [w^n]
expleft(-frac{kn}{m}logfrac{1}{1-(-w)^m}right)
= sum_{p=1}^{n-1} [w^n] (1-(-w)^{n/gcd(p, n)})^{kgcd(p, n)}
\ = sum_{p=1}^{n-1} [w^n] (1+(-1)^{1+n/gcd(p, n)}
w^{n/gcd(p, n)})^{kgcd(p, n)}.$$



This is



$$sum_{p=1}^{n-1} {kgcd(p,n) choose gcd(p,n)}
(-1)^{(1+n/gcd(p, n)) gcd(p,n)}.$$



Putting it all together we thus obtain



$$bbox[5px,border:2px solid #00A000]{
frac{1}{n} + (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{p=1}^{n-1} {kgcd(p,n) choose gcd(p,n)}
(-1)^{gcd(p,n)}.}$$



While this formula will produce results it may perhaps be simplified.
Write



$$frac{1}{n} =
(-1)^n {knchoose n}^{-1} frac{1}{n}
{kgcd(n,n)choose gcd(n,n)} (-1)^{gcd(n,n)}$$



to get



$$(-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{p=1}^{n}
{kgcd(p, n)choose gcd(p,n)}
(-1)^{gcd(p,n)}
\ = (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} sum_{gcd(p,n)=d}
{kdchoose d}
(-1)^{d}
\ = (-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} {kdchoose d}
(-1)^{d} sum_{gcd(q,n/d)=1} 1.$$



We find the alternate closed form



$$bbox[5px,border:2px solid #00A000]{
(-1)^n
{knchoose n}^{-1} frac{1}{n}
sum_{d|n} {kdchoose d}
(-1)^d varphi(n/d).}$$



These two formulae were verified by simple enumeration for $1le nle
7$ and $1le kle 6,$ see below.




with(combinat);
with(numtheory);

ENUM :=
proc(k, n)
option remember;
local recurse, admit, total;

admit := 0; total := 0;

recurse :=
proc(pos, selcount, sumsofar)
if selcount = n then
if sumsofar mod n = 0 then
admit := admit + 1;
fi;

total := total + 1;

return;
fi;

if pos > k*n then return fi;

recurse(pos+1, selcount, sumsofar);
recurse(pos+1, selcount + 1,
sumsofar + pos);
end;

recurse(1, 0, 0);
admit/total;
end;

X := (k, n) ->
1/n+(-1)^n*binomial(k*n,n)^(-1)*1/n
* add(binomial(k*gcd(p,n),gcd(p,n))*(-1)^gcd(p,n),
p=1..n-1);

XX := (k, n) ->
(-1)^n*binomial(k*n,n)^(-1)*1/n
* add(binomial(k*d,d)*(-1)^d*phi(n/d),
d in divisors(n));



Remark. This computation is based on material from this MSE
link.







share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited Aug 26 '18 at 18:14

























answered Aug 26 '18 at 14:44









Marko RiedelMarko Riedel

40.5k339109




40.5k339109












  • $begingroup$
    This proof looks nice! Unfornately it is quite above my level so I need time to understand it. Nice work!
    $endgroup$
    – Gareth Ma
    Aug 26 '18 at 23:37


















  • $begingroup$
    This proof looks nice! Unfornately it is quite above my level so I need time to understand it. Nice work!
    $endgroup$
    – Gareth Ma
    Aug 26 '18 at 23:37
















$begingroup$
This proof looks nice! Unfornately it is quite above my level so I need time to understand it. Nice work!
$endgroup$
– Gareth Ma
Aug 26 '18 at 23:37




$begingroup$
This proof looks nice! Unfornately it is quite above my level so I need time to understand it. Nice work!
$endgroup$
– Gareth Ma
Aug 26 '18 at 23:37


















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematics Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2894653%2fnumber-of-n-element-subsets-of-1-2-dotsc-3n-with-sum-divisible-by-n%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Quarter-circle Tiles

build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

Mont Emei