Some Elementary Congruences for the Number of Weighted Integer Compositions

Steffen Eger Computer Science Department Goethe University Frankfurt am Main 60325 Frankfurt am Main Germany

                eger.steffen@gmail.com

Abstract

An integer composition of a nonnegative integer n is a tuple (π_{1}, …, π_{k}) of nonnegative integers whose sum is n; the π_{i}’s are called the parts of the composition. For fixed number k of parts, the number of f-weighted integer compositions (also called f-colored integer compositions in the literature), in which each part size s may occur in f(s) different colors, is given by the extended binomial coefficient \binom{k}{n}_{f}. We derive several congruence properties for \binom{k}{n}_{f}, most of which are analogous to those for ordinary binomial coefficients. Among them is the parity of \binom{k}{n}_{f}, Babbage’s congruence, Lucas’ theorem, etc. We also give congruences for c_{f}(n), the number of f-weighted integer compositions with arbitrarily many parts, and for extended binomial coefficient sums. We close with an application of our results to prime criteria for weighted integer compositions.

1 Introduction

An integer composition (ordered partition) of a nonnegative integer n is a tuple (π_{1}, …, π_{k}) of nonnegative integers whose sum is n; the π_{i}’s are called the parts of the composition. We call an integer composition of n f-weighted, for a function f : ℕ → ℕ, whereby ℕ denotes the set of nonnegative integers, if each part size s ∈ ℕ may occur in f(s) different colors in the composition. If f is the indicator function of a subset A ⊆ ℕ, this yields the socalled A-restricted integer compositions [13];^{1} if f(s) = s, this yields the so-called s-colored compositions [1].

To illustrate, let f(1) = f(2) = f(3) = 1 and f(9) = 3, and let f(s) = 0, for all s ∈ ℕ\{1, 2, 3, 9}. Then, there are 4! · 3 + 4 · 3 = 84 different f-weighted integer compositions of n = 15 with exactly k = 4 parts, among them,

(1, 3, 2, 9^{1}), (1, 3, 2, 9^{2}), (1, 3, 2, 9^{3}),

where we superscript the different colors of part size 9. Obviously, k = 4 divides 4! · 3 + 4 · 3, and this is not coincidental and does not depend upon f, as we will show. More generally, we derive several divisibility properties of the number of f-weighted integer compositions. First, after reviewing some introductory background regarding weighted integer compositions, their relations to extended binomial coefficients, and elementary properties of weighted integer compositions in Section 2, we consider divisibility properties for f-weighted integer compositions with a fixed number k of parts in Section 3. Then, in Section 4, we combine several known results to derive divisibility properties for the number of f-weighted integer compositions of n with arbitrarily many parts. In the same section, we also specify divisibility properties for extended binomial coefficient sums. Lastly, in Section 5, we close with an application of our results to prime criteria for weighted integer compositions.

To place our work in some context, we note that there is a large body of recent results on integer compositions. To name just a few examples, Heubach and Mansour [13] investigate generating functions for the so-called A-restricted compositions; Sagan [27] considers doubly restricted integer compositions; Agarwal [1], Narang and Agarwal [22], Guo [12], Hopkins [15], Shapcott [28, 29], and Mansour and Shattuck [17] study results for s-colored integer compositions. Mansour, Shattuck, and Wilson [18], Munagi [20], and Munagi and Sellers [21] count the number of compositions of an integer in which (adjacent) parts satisfy congruence relationships. Probabilistic results for (restricted) integer compositions are provided in Ratsaby [24], Neuschel [23], and in Banderier and Hitczenko [4], among many others. Mihoubi [19] studies congruences for the partial Bell polynomials, which may be considered special cases of weighted integer compositions [9]. Classical results on weighted integer compositions are, for example, provided in Hoggatt and Lind [14] and some congruence relationships for classical extended binomial coefficients are given, e.g., in Bollinger and Burchard [6] and Bodarenko [5].

1In particular, if f is the indicator function of the nonnegative integers, then this yields the so-called weak compositions and if f is the indicator function of the positive integers, this yields the ordinary integer compositions.

2 Number of f-weighted integer compositions with fixed number of parts

For k ≥ 0 and n ≥ 0, consider the coefficient of x^{n} of the polynomial or power series

(∑_{s∈ℕ} f(s)x^{s})^{k},  (1)

and denote it by \binom{k}{n}_{f}. Our first theorem states that \binom{k}{n}_{f} denotes the combinatorial object we are investigating in this work, f-weighted integer compositions.

Theorem 1. The number \binom{k}{n}_{f} denotes the number of f-weighted integer compositions of n with k parts.

Proof. Collecting terms in (1), we see that [x^{n}]g(x), for g(x) = (∑_{s∈ℕ} f(s)x^{s})^{k}, is given as

∑_{π_{1}+···+π_{k}=n} f(π_{1}) ⋯ f(π_{k}),  (2)

where the sum is over all nonnegative integer solutions to π_{1} + … + π_{k} = n. This proves the theorem.

Theorem 1 has appeared, for example, in Shapcott [28], Eger [7], or, much earlier, in Hoggatt and Lind [14]. Note that \binom{k}{n}_{f}, which has also been referred to as extended binomial coefficient in the literature [10], generalizes many interesting combinatorial objects, such as the binomial coefficients (for f(0) = f(1) = 1 and f(s) = 0, for s > 1) \underline{A007318}, trinomial coefficients \underline{A027907}, etc.

We now list four relevant properties of the f-weighted integer compositions, which we will make use of in the proofs of congruence properties later on. Throughout this work, we will denote the ordinary binomial coefficients, i.e., when f(0) = f(1) = 1 and f(s) = 0 for all s > 1, by the standard notation \binom{k}{n}.

Theorem 2 (Properties of f-weighted integer compositions). Let k, n ≥ 0. Then, the following hold true:

\binom{k}{n}_{f} = ∑_{\begin{matrix}k_{0}+···+k_{n}=k \\ 0·k_{0}+···n·k_{n}=n \end{matrix}} \binom{k}{k_{0}, …, k_{n}} ∏_{i=0}^{n} f(i)^{k_{i}}  (3)

\binom{k}{n}_{f} = ∑_{μ_{1}+···+μ_{r}=n} \binom{k_{1}}{μ_{1}}_{f} \binom{k_{2}}{μ_{2}}_{f} ⋯ \binom{k_{r}}{μ_{r}}_{f}  (4)

\binom{k}{n}_{f} = \frac{k}{in} ∑_{s∈ℕ} s\binom{i}{s}_{f} \binom{k − i}{n − s}_{f}  (5)

\binom{k}{n}_{f} = ∑_{i∈ℕ} f(ℓ)^{i}\binom{k}{i}\binom{k − i}{n − ℓi}_{f_{|f(ℓ)=0}}  (6)

In (3), the sum is over all solutions in nonnegative integers k_{0}, …, k_{n} of k_{0} + ⋯ + k_{n} = n and 0 · k_{0} + ⋯ + nk_{n} = n, and \binom{k}{k_{0},...,k_{n}} = \frac{k!}{k_{0}!···k_{n}!} denote the multinomial coefficients. In (4), which is also sometimes called Vandermonde convolution [10], the sum is over all solutions in nonnegative integers μ_{1}, …, μ_{r} of μ_{1} + ⋯ + μ_{r} = n, and the relationship holds for any fixed composition (k_{1}, …, k_{r}) of k, for r ≥ 1. In (5), i is an integer satisfying 0 < i ≤ k. In (6), ℓ ∈ ℕ and by f_{|f(ℓ)=0} we denote the function g : ℕ → ℕ for which g(s) = f(s), for all s ≠ ℓ, and g(ℓ) = 0.

Proof. (3) follows from rewriting the sum in (2) as a summation over integer partitions rather than over integer compositions and then adjusting the factors in the sum. (4) and (6) have straightforward combinatorial interpretations, and proofs can be found in Fahssi [10] and Eger [7]. For a proof of (5), note first that \binom{k}{n}_{f} also represents the distribution of the sum of i.i.d. nonnegative integer-valued random variables X_{1}, …, X_{k}. Namely, let P [X_{i} = s] = \frac{f(s)}{∑_{s′∈ℕ} f(s′)} (wlog, we may assume ∑_{s′∈ℕ} f(s′) to be finite). Then, using (2),

P [X_{1} + ⋯ + X_{k} = n] = ∑_{π_{1}+···+π_{k}=n} P [X_{1} = π_{1}] ⋯ P [X_{k} = π_{k}] = (\frac{1}{∑_{s′∈ℕ} f(s′)})^{k} \binom{k}{n}_{f}.

Thus, it suffices to prove (5) for sums of random variables. For 0 < i ≤ k, let S_{i} denote the partial sum X_{1} + ⋯ + X_{i}. Then, consider the conditional expectation E[S_{i} | S_{k} = n], for which the relation

E[S_{i} | S_{k} = n] = \frac{n}{k}i,

holds, by independent and identical distribution of X_{1}, …, X_{k}. Moreover, by definition of conditional expectation, we have that

E[S_{i} | S_{k} = n] = ∑_{s∈ℕ} s\frac{P [S_{i} = s, S_{k} = n]}{P [S_{k} = n]} = ∑_{s∈ℕ} s\frac{P [S_{i} = s] · P [S_{k−i} = n − s]}{P [S_{k} = n]}.

Combining the two identities for E[S_{i} | S_{k} = n] and rearranging yields (5).

Remark 3. Note the following important special case of (4) which results when we let r = 2 and k_{1} = 1 and k_{2} = k − 1,

\binom{k}{n}_{f} = ∑_{μ=0}^{n} f(μ)\binom{k − 1}{n − μ}_{f},

which establishes that the quantities \binom{k}{n}_{f} may be perceived of as generating a Pascal-triangle-like array in which entries in row k are weighted sums of the entries in row k−1. To illustrate, the left-justified triangle for f(0) = 5, f(1) = 0, f(2) = 2, f(3) = 1, f(x) = 0, for all x > 3, starts as

k\n 0 1 2 3 4 5 6 7 8 9 ⋯
0  1
1  5 0 2 1
2 25 0 20 10 4 4 1
3 125 0 150 75 60 60 23 12 6 1
⋮  ⋮ · · · · · · · · · · · · · · · · · · · · · · · · · · · ...

We also note the following special cases of \binom{k}{n}_{f}, which we will make use of in Section 3. Lemma 4. For all x, k ∈ ℕ, we have that

\binom{k}{0}_{f} = f(0)^{k},
\binom{k}{1}_{f} = kf(1)f(0)^{k−1},
\binom{1}{x}_{f} = f(x),
\binom{0}{x}_{f} = \begin{cases}1, & if x = 0; \\ 0, & otherwise. \end{cases}

3 Some elementary divisibility properties of the number of f-weighted integer compositions with fixed number of parts

Theorem 5 (Parity of extended binomial coefficients).

\binom{k}{n}_{f} ≡ \begin{cases}0 (mod 2), & if k is even and n is odd; \\ \binom{k/2}{n/2}_{f} (mod 2), & if k is even and n is even; \\ ∑_{s≥0} f(2s + p(n))\binom{⌊k/2⌋}{⌊n/2⌋−s}_{f} (mod 2), & if k is odd; \end{cases}

where we let p(n) = 0 if n is even and p(n) = 1 otherwise. Proof. We distinguish three cases.

• Case 1: Let k be even and n odd. In (5) in Theorem 1 with i = 1, multiply both sides by n. If k is even, the right-hand side is even, and thus, if n is odd, \binom{k}{n}_{f} must be even.

• Case 2: Let k be even and n even. Consider the Vandermonde convolution in the case when r = 2 and j = k/2. Then,

\binom{k}{n}_{f} = ∑_{μ+ν=n} \binom{k/2}{μ}_{f} \binom{k/2}{ν}_{f} = 2 ∑_{0≤μ<n/2} \binom{k/2}{μ}_{f} \binom{k/2}{n − μ}_{f} + \binom{k/2}{n/2}_{f}

≡ \binom{k/2}{n/2}_{f} (mod 2).

• Case 3: Let k be odd. Then k − 1 is even. Thus, the Vandermonde convolution with j = 1, r = 2 implies

\binom{k}{n}_{f} = ∑_{s∈ℕ} f(s)\binom{k − 1}{n − s}_{f} ≡ ∑_{\{s∈ℕ | n−s is even\}} f(s)(\frac{k−1}{2} ; \frac{n−s}{2})_{f} (mod 2),

where we use Case 1 and Case 2 in the last congruence. Hence, if n is even,

\binom{k}{n}_{f} ≡ ∑_{s≥0} f(2s)\binom{⌊k/2⌋}{\frac{n}{2} − s}_{f} (mod 2),

and if n is odd,

\binom{k}{n}_{f} ≡ ∑_{s≥0} f(2s + 1)\binom{⌊k/2⌋}{⌊n/2⌋ − s}_{f} (mod 2).

Example 6. Let f(0) = 3, f(1) = 2, f(2) = 1 and f(s) = 0 for all s > 2. Then, by Theorem 5,

\binom{13}{14}_{f} ≡ f(0)\binom{6}{7}_{f} + f(2)\binom{6}{6}_{f} + \underbrace{f(4)\binom{6}{5}_{f} + ⋯}_{=0} ≡ 0 + \binom{3}{3}_{f}

≡ f(1)\binom{1}{1}_{f} + \underbrace{f(3)\binom{1}{0}_{f} + ⋯}_{=0} = 2\binom{1}{1}_{f} ≡ 0 (mod 2),

and, in fact, \binom{13}{14}_{f} = 289, 159, 780.

Theorem 7. Let p be prime. Then

\binom{p}{n}_{f} ≡ \begin{cases}f(r) (mod p), & if n = pr for some r; \\ 0 (mod p), & else. \end{cases}

We sketch three proofs of Theorem 7, a combinatorial proof and two proof sketches based on identities in Theorem 2. The first proof is based on the following lemma [2].

Lemma 8. Let S be a finite set, let p be prime, and suppose g : S → S has the property that g^{p}(x) = x for any x in S, where g^{p} is the p-fold composition of g. Then |S| ≡ |F | (mod p), where F is the set of fixed points of g.

Proof of Theorem 7, 1. For an f-weighted integer composition of n with p parts, let g be the operation that shifts all parts one to the right, modulo p. In other words, g maps (denoting different colors by superscripts) (π_{1}^{α_{1}}, π_{2}^{α_{2}}, …, π_{p−1}^{α_{p−1}}, π_{p}^{α_{p}}) to

(π_{p}^{α_{p}}, π_{1}^{α_{1}}, π_{2}^{α_{2}}, …, π_{p−1}^{α_{p−1}}).

Of course, applying g p times yields the original f-colored integer composition, that is, g^{p}(x) = x for all x. We may thus apply Lemma 8. If n allows a representation n = pr for some suitable r, g has exactly f(r) fixed points, namely, all compositions \underbrace{(r^{1}, …, r^{1})}_{p times} to

\underbrace{(r^{f(r)}, …, r^{f(r)})}_{p times}. Otherwise, if n has no such representation, g has no fixed points. This

proves the theorem.

Proof of Theorem 7, 2. We apply (6) in Theorem 2. Since for the ordinary binomial coefficients, the relation \binom{p}{n} ≡ 0 (mod p) holds for all 1 ≤ n ≤ p − 1 and \binom{p}{0} = \binom{p}{p} = 1, we have

\binom{p}{n}_{f} ≡ \binom{p}{n}_{f_{|f(ℓ)=0}} + f(ℓ)^{p}\binom{0}{n − ℓp}_{f_{|f(ℓ)=0}} ≡ \binom{p}{n}_{f_{|f(ℓ)=0}} + f(ℓ)\binom{0}{n − ℓp}_{f_{|f(ℓ)=0}} (mod p),

for any ℓ and where the last congruence is due to Fermat’s little theorem. Therefore, if n = rp for some r, then \binom{p}{n}_{f} ≡ \binom{p}{n}_{f_{|f(r)=0}} + f(r) (mod p) and otherwise \binom{p}{n}_{f} ≡ \binom{p}{n}_{f_{|f(ℓ)=0}} (mod p) for any ℓ. Now, the theorem follows inductively.

Proof of Theorem 7, 3. Finally, we can use (3) in Theorem 2 in conjunction with the following property of multinomial coefficients (see, e.g., Ricci [25]), namely,

\binom{k}{k_{0}, …, k_{n}} ≡ 0 (mod \frac{k}{gcd (k_{0}, …, k_{n})}).  (7)

From this, whenever n ≠ pr, \binom{p}{n}_{f} ≡ 0 (mod p) since for all terms in the summation in (3), gcd (k_{0}, …, k_{n}) = 1. Otherwise, if n = pr for some r, then gcd (k_{0}, …, k_{n}) > 1 precisely when one of the k_{i}’s is p and the remaining are zero. Since also 0k_{0} + ⋯ + nk_{n} = n = rp, this can only occur when k_{r} = p. Hence, \binom{p}{rp}_{f} ≡ \binom{p}{0,...,p,...,0}f(r)^{p} ≡ f(r) (mod p).

The next immediate corollary generalizes the congruence (1 + x)^{p} ≡ 1 + x^{p} (mod p), for p prime.

Corollary 9. Let p be prime. Then,

(∑_{s∈ℕ} f(s)x^{s})^{p} = ∑_{n∈ℕ} \binom{p}{n}_{f}x^{n} ≡ ∑_{r∈ℕ} f(r)x^{pr} (mod p).

Corollary 10. Let k, s ≥ 0 and p prime. Then,

\binom{k + sp}{j}_{f} ≡ \binom{k}{j}_{f}f(0)^{sp} (mod p),

for 0 ≤ j < p. Proof. By the Vandermonde convolution, (4), we have

\binom{k + sp}{j}_{f} = ∑_{x+y=j} \binom{k}{x}_{f} \binom{sp}{y}_{f}.

Now, again by the Vandermonde convolution, \binom{sp}{y}_{f} = ∑_{x_{1}+···+x_{s}=y} \binom{p}{x_{1}}_{f} ⋯ \binom{p}{x_{s}}_{f}. Since 0 ≤ y ≤ j < p, the product ∏ \binom{p}{x_{i}}_{f} is divisible by p by Theorem 7 whenever x_{1} = ⋯ = x_{s} = 0 does not hold. Therefore,

\binom{k + sp}{j}_{f} ≡ \binom{k}{j}_{f} \binom{sp}{0}_{f} = \binom{k}{j}_{f}f(0)^{sp} (mod p),

by Lemma 4. Corollary 11. Let p be prime and 0 ≤ m, r with r < p. Then,

\binom{p + 1}{mp + r}_{f} ≡ ∑_{s≥0} f(r + sp)f(m − s) (mod p).

Proof. This follows from \binom{p+1}{n}_{f} = ∑_{s≥0} f(s)\binom{p}{n−s}_{f} and Theorem 7. Remark 12. Similar results as in Corollary 11 can be derived for \binom{p+2}{mp+r}_{f}, etc., but the formulas become more complicated.

With similar arguments as before, we can also prove a stronger version of Theorem 7, namely: Theorem 13. Let p be prime and let m ≥ 1. Then

\binom{p^{m}}{n}_{f} ≡ \begin{cases}f(r) (mod p), & if n = p^{m}r for some r; \\ 0 (mod p), & else. \end{cases}

We call the next congruence Babbage’s congruence, since Charles Babbage was apparently the first to assert the respective congruence in the case of ordinary binomial coefficients [3].

Theorem 14 (Babbage’s congruence). Let p be prime, and let n and m be nonnegative integers. Then

\binom{np}{mp}_{f} ≡ \binom{n}{m}_{g} (mod p^{2}),

whereby g is defined as g(r) = \binom{p}{rp}_{f}, for all r ∈ ℕ.

Proof. By the Vandermonde convolution, we have

\binom{np}{mp}_{f} = ∑_{k_{1}+···+k_{n}=mp} \binom{p}{k_{1}}_{f} ⋯ \binom{p}{k_{n}}_{f}  (8)

Now, by Theorem 7, p divides \binom{p}{x}_{f} whenever x is not of the form x = pr. Hence, modulo p^{2}, the only terms that contribute to the sum are those for which at least n − 1 k_{i}’s are of the form k_{i} = r_{i}p. Since the k_{i}’s must sum to mp, this implies that all k_{i}’s are of the form k_{i} = r_{i}p, for i = 1, …, n. Hence, modulo p^{2}, (8) becomes

∑_{r_{1}+···+r_{n}=m} ∏_{i=1}^{n} \binom{p}{r_{i}p}_{f} = ∑_{r_{1}+···+r_{n}=m} ∏_{i=1}^{n} g(r_{i}),

The last sum is precisely \binom{n}{m}_{g}.

Corollary 15. Let r ≥ 0 and let p be prime. Then

\binom{pr}{p}_{f} ≡ \binom{p}{p}_{f}f(0)^{p(r−1)}r (mod p^{2}).

Proof. This follows by combining Theorem 14 and Lemma 4.

Now, we consider the case when x in \binom{np}{x}_{f} is not of the form mp for some m.

Theorem 16. Let p be prime and let s, r be nonnegative integers. Let p not divide r. Then,

\binom{sp}{r}_{f} ≡ s · ∑_{\{0≤i_{1}≤r | r−i_{1}=m_{i_{1}}p\}} \binom{p}{i_{1}}_{f} \binom{s − 1}{m_{i_{1}}}_{g} (mod p^{2}),

where g is as defined in Theorem 14.

Proof. By the Vandermonde convolution, (4), we find that

\binom{sp}{r}_{f} = ∑_{i_{1}+···+i_{s}=r} \binom{p}{i_{1}}_{f} ⋯ \binom{p}{i_{s}}_{f} = ∑_{i_{1}=0}^{r} \binom{p}{i_{1}}_{f} ∑_{i_{2}+···+i_{s}=r−i_{1}} \binom{p}{i_{2}}_{f} ⋯ \binom{p}{i_{s}}_{f}.

Now, \binom{p}{x}_{f} ≡ 0 (mod p) whenever x is not of the form x = ap, by Theorem 7. Thus, modulo p^{2}, the above RHS is ≡ 0 unless for at least s − 1 factors \binom{p}{i_{j}}_{f} we have that i_{j} = a_{j}p for some a_{j}. Not all s factors can be of the form a_{j}p, since otherwise i_{1} +⋯+i_{s} = p(a_{1} +⋯+a_{s}) = r, contradicting that p ∤ r. Hence, exactly s − 1 factors must be of the form a_{j}p, and therefore,

\binom{sp}{r}_{f} ≡ s ∑_{i_{1}=0,p∤i_{1}}^{r} \binom{p}{i_{1}}_{f} ∑_{a_{2}p+···+a_{s}p=r−i_{1}} \binom{p}{a_{2}p}_{f} ⋯ \binom{p}{a_{s}p}_{f}

= s ∑_{i_{1}=0,p∤i_{1}}^{r} \binom{p}{i_{1}}_{f} ∑_{a_{2}p+···+a_{s}p=r−i_{1}} g(a_{2}) ⋯ g(a_{s}) (mod p^{2}),

Now, the equation p(a_{2} +⋯+a_{s}) = a_{2}p+⋯+a_{s}p = r−i_{1} has solutions only when p | r−i_{1}, that is, when there exists m_{i_{1}} such that r − i_{1} = m_{i_{1}}p.

Corollary 17. Let p be prime, s ≥ 0 and let 0 ≤ r ≤ p. Then,

\binom{sp}{r}_{f} ≡ s\binom{p}{r}_{f} · f(0)^{p(s−1)} (mod p^{2}).

Proof. For r = p, this is Corollary 15. For 0 ≤ r < p, the proof follows from Theorem 16 by noting that i_{1} = r and m_{i_{1}} = 0 is the only solution to the sum constraint.

Corollary 17 immediately implies the following:

Corollary 18. Let 0 ≤ r, s ≤ p. Then,

f(0)^{p(s−1)}s\binom{rp}{r}_{f} ≡ f(0)^{p(r−1)}r\binom{sp}{r}_{f} (mod p^{2}).

Theorem 19. Let m, k, n ≥ 0 be nonnegative integers. Then

\binom{mk}{n}_{f} ≡ 0 (mod \frac{k}{gcd (k, n)}).

Proof. From (5), with i = 1, write

\frac{1}{d}n\binom{mk}{n}_{f} = \frac{1}{d}mk ∑_{s∈ℕ} sf(s)\binom{mk − 1}{n − s}_{f} = \frac{k}{d}A,

where A ∈ ℕ, d = gcd(k, n) and note that gcd(k/d, n/d) = 1.

Theorem 20. Let p be prime and r ≥ 1 arbitrary. Then,

\binom{pr}{p}_{f} ≡ f(0)^{p(r−1)}f(1)^{p}\binom{pr}{p} (mod pr).

Proof. From (3), \binom{pr}{p}_{f} can be written as

\binom{pr}{p}_{f} = ∑_{\begin{matrix}k_{0}+···+k_{p}=pr, \\ 0·k_{0}+···+p·k_{p}=p \end{matrix}} \binom{pr}{k_{0}, …, k_{p}} ∏_{s=0}^{p} f(s)^{k_{s}}.  (9)

For a term in the sum, either d = gcd(k_{0}, …, k_{p}) = 1 or d = p, since otherwise, if 1 < d < p, then d · (0 · k_{0}/d + ⋯ p · k_{p}/d) = p, whence p is composite, a contradiction. Those terms on the RHS of (9) for which d = 1 contribute nothing to the sum modulo pr, by (7), so they can be ignored. But, from the equation 0 · k_{0} + 1 · k_{1} + ⋯ p · k_{p} = p, the case d = p precisely happens when k_{1} = p, k_{2} = ⋯ = k_{p} = 0 and when k_{0} = p(r −1) (from the equation k_{0} + ⋯ + k_{p} = pr), whence, as required, \binom{pr}{p}_{f} ≡ f(0)^{p(r−1)}f(1)^{p}\binom{pr}{p} (mod pr).

Recall that the ordinary binomial coefficients satisfy Lucas’ theorem, namely,

\binom{k}{n} ≡ ∏ \binom{k_{i}}{n_{i}} (mod p),

whenever k = ∑ n_{i}p^{i} and n = ∑ k_{i}p^{i} with 0 ≤ n_{i}, k_{i} < p. An analogous result has been established in Bollinger and Burchard [6] for the classical extended binomial coefficients, the coefficients of (1 + x + … + x^{m})^{k}. We straightforwardly extend their result for our more general situation of arbitrarily weighted integer compositions (general extended binomial coefficients).

Theorem 21 (Lucas’ theorem). Let p be a prime and let n = ∑_{i=0}^{t} n_{i}p^{i} and k = ∑_{j=0}^{r} k_{j}p^{j}, where 0 ≤ n_{i}, k_{j} < p. Then

\binom{k}{n}_{f} ≡ ∑_{(s_{0},...,s_{r})} ∏_{i=0}^{r} \binom{k_{i}}{s_{i}}_{f} (mod p),

whereby the sum is over all (s_{0}, …, s_{r}) that satisfy s_{0} + s_{1}p + ⋯ + s_{r}p^{r} = n.

Proof.

∑_{n≥0} \binom{k}{n}_{f}x^{n} = (∑_{s≥0} f(s)x^{s})^{k} = ∏_{j=0}^{r} (∑_{s≥0} f(s)x^{s})^{k_{j}p^{j}} ≡ ∏_{j=0}^{r} (∑_{s≥0} f(s)x^{p^{j}s})^{k_{j}}

= ∏_{j=0}^{r} (∑_{m≥0} \binom{k_{j}}{m}_{f}x^{p^{j}m}) = ∑_{n≥0} ( ∑_{(s_{0},...,s_{r})} \binom{k_{0}}{s_{0}}_{f} ⋯ \binom{k_{r}}{s_{r}}_{f} ) x^{n} (mod p),

where the third equality follows from Theorem 13, and the theorem follows by comparing the coefficients of x^{n}.

Finally, we conclude this section with a theorem given in Granville [11] which allows a ‘fast computation’ of \binom{k}{n}_{f} modulo a prime.

Theorem 22. Let p be a prime. Then,

\binom{k}{n}_{f} ≡ ∑_{m≥0} \binom{⌊k/p⌋}{⌊n/p⌋ − m}_{f} \binom{k_{0}}{n_{0} + mp}_{f} (mod p),

whereby n_{0} and k_{0} are the remainders when dividing n and k by p.

Proof. We have

(∑_{s≥0} f(s)x^{s})^{p} ≡ ∑_{s≥0} f(s)x^{ps} (mod p)

by Theorem 7 and therefore, with k = k_{0} + k_{1}p, for 0 ≤ k_{0}, k_{1} < p,

(∑_{s≥0} f(s)x^{s})^{k_{0}+k_{1}p} ≡ (∑_{s≥0} f(s)x^{s})^{k_{0}} (∑_{s≥0} f(s)x^{ps})^{⌊k/p⌋}

= ∑_{r,t≥0} \binom{⌊k/p⌋}{t}_{f} \binom{k_{0}}{r}_{f}x^{pt+r} (mod p).

Now, since \binom{k}{n}_{f} is the coefficient of x^{n} of (∑_{s≥0} f(s)x^{s})^{k_{0}+k_{1}p},

\binom{k}{n}_{f} ≡ ∑_{pt+r=n} \binom{⌊k/p⌋}{t}_{f} \binom{k_{0}}{r}_{f} (mod p),

and the theorem follows after re-indexing the summation on the RHS.

4 Divisibility of the number of f-weighted integer compositions of n with arbitrary number of parts k, and where n ∈ A

Here, we (briefly) consider divisibility properties for the number c_{f}(n) of integer compositions with arbitrary number of parts, i.e., c_{f}(n) = ∑_{k≥0} \binom{k}{n}_{f}, and, in Theorems 30 and 31, particular divisibility properties for the total number of all f-weighted integer compositions of n ∈ A, for sets A, with fixed number k of parts, i.e., ∑_{n∈A} \binom{k}{n}_{f}.

First, it is easy to establish that c_{f}(n) is a ‘generalized Fibonacci sequence’, satisfying a weighted linear recurrence where the weights are given by f.

Theorem 23. For n ≥ 1 we have that

c_{f}(n) = ∑_{m∈ℕ} f(m)c_{f}(n − m),

where we define c_{f}(0) = 1 and c_{f}(n) = 0 if n < 0.

Proof. An f-weighted integer composition of n may end, in its last part, with one of the values m = 0, 1, 2, …, n, and m may be colored in f(m) different colors.

Remark 24. Of course, when f(0) > 0, then c_{f}(n) > 0 ⟹ c_{f}(n) = ∞ for all positive n. Hence, in the remainder, we assume that f(0) = 0.

In special cases, e.g., when f is the indicator function of particular sets B ⊆ ℕ, that is,

f(s) = 𝟙_{B}(s) = \begin{cases}1, & if s ∈ B; \\ 0, & otherwise \end{cases}, it is well-known that c_{f}(n) is closely related to the ordinary

Fibonacci numbers F_{n}. For example (see, e.g., Shapcott [29]):

c_{f}(n) = F_{n+1}, for f = 𝟙_{{1,2}},
c_{f}(n) = F_{n−1}, for f = 𝟙_{ℕ\{0,1}},
c_{f}(n) = F_{n}, for f = 𝟙_{{n∈ℕ | n is odd}},
c_{f}(n) = F_{2n}, for f(s) = s = Id(s).

Accordingly, it immediately follows that c_{f}(n), in these cases, satisfies the corresponding divisibility properties of the Fibonacci numbers, such as the following well-known properties.

Theorem 25. Let p be prime. Then

c_{𝟙_{\{1,2\}}}(p − 1) ≡ c_{𝟙_{ℕ\\{0,1\}}}(p + 1) ≡ c_{𝟙_{\{n∈ℕ | n is odd\}}}(p) ≡ \begin{cases}0, & if p = 5; \\ 1, & if p ≡ ±1 (mod 5); \\ −1, & if p ≡ ±2 (mod 5). \end{cases} (mod p).

Moreover,

gcd (c_{𝟙_{{1,2}}}(m), c_{𝟙_{{1,2}}}(n)) = c_{𝟙_{{1,2}}}(gcd(m + 1, n + 1) − 1),
gcd (c_{𝟙_{ℕ\{0,1}}}(m), c_{𝟙_{ℕ\{0,1}}}(n)) = c_{𝟙_{ℕ\{0,1}}}(gcd (m − 1, n − 1) + 1),
gcd(c_{𝟙_{{n∈ℕ | n is odd}}}(m), c_{𝟙_{{n∈ℕ | n is odd}}}(n)) = c_{𝟙_{{n∈ℕ | n is odd}}}(gcd(m, n)),
gcd(c_{Id}(m), c_{Id}(n)) = c_{Id}(gcd (m, n)).

Remark 26. Note how Theorem 25 implies several interesting properties, such as 3 | c_{Id}(4m) (since gcd(4m, 2) = 2 and c_{Id}(2) = 3, as 2 = 1 + 1 = 2^{1} = 2^{2}) or, similarly, 7 | c_{Id}(4m), which otherwise also follow from well-known congruence relationships for Fibonacci numbers.

When f is arbitrary but zero almost everywhere (f(x) = 0 for all x > m, for some m ∈ ℕ), then by Theorem 23, c_{f}(n) satisfies an m-th order linear recurrence, given by

c_{f}(n + m) = f(1)c_{f}(n + m − 1) + ⋯ + f(m)c_{f}(n).

For such sequences, Somer [30, Theorem 4], for instance, states a congruence relationship which we can immediately apply to our situation, leading to:

Theorem 27. Let p be a prime and let b a nonnegative integer. Let f : ℕ → ℕ be zero almost everywhere, i.e., f(x) = 0 for all x > m. Then

c_{f}(n + mp^{b}) ≡ f(1)c_{f}(n + (m − 1)p^{b}) + f(2)c_{f}(n + (m − 2)p^{b}) + ⋯ + f(m)c_{f}(n) (mod p).

Example 28. Let f(1) = 1, f(2) = 3, f(3) = 0, f(4) = 2. Let p = 5 and x = 20 = n+mp = 0 + 4 · 5. Then,

f(1)c_{f}(15) + f(2)c_{f}(10) + f(3)c_{f}(5) + f(4)c_{f}(0) = 290375 + 3 · 3693 + 0 · 44 + 2 · 1
≡ 11081 ≡ 1 (mod 5),

and, indeed, c_{f}(20) = 22, 985, 976 ≡ 1 (mod 5).

Example 29. When f ‘avoids’ a fixed arithmetic sequence, i.e., f(s) = 1 whenever s ∉ {a + mj | j ∈ ℕ}, for a, m ∈ ℕ fixed, and otherwise f(s) = 0, then c_{f}(n) likewise satisfies a linear recurrence [26], namely,

c_{f}(n + m) = c_{f}(n + m − 1) + ⋯ + c_{f}(n + m − a + 1) + c_{f}(n + m − a − 1) + ⋯
+ c_{f}(n + 1) + 2c_{f}(n),

and so Theorem 27 applies likewise.

Finally, we consider the number of f-weighted compositions, with fixed number of parts, of all numbers n in some particular sets A. Introduce the following notation:

\left[{k \atop r}\right]_{m,f} = ∑_{n≡r (mod m)^{n≥0}} \binom{k}{n}_{f}.

Note that \left[{k \atop r}\right]_{m,f} generalizes the usual binomial sum notation (cf. Sun [31]). In our context, \left[{k \atop r}\right]_{m,f} denotes the number of compositions, with k parts, of n ∈ A = \{y | y ≡ r (mod m)\}. We note that, by the Vandermonde convolution, \left[{k \atop r}\right]_{m,f} satisfies

\left[{k \atop r}\right]_{m,f} = ∑_{s≥0} f(s)\left[{k − 1 \atop r − s}\right]_{m,f}.  (10)

Our first theorem in this context goes back to J. W. L. Glaisher, and its proof is inspired by the corresponding proof for binomial sums due to Sun (cf. Sun [31], and references therein).

Theorem 30 (Glaisher). For any prime p ≡ 1 (mod m) and any k ≥ 1,

\left[{k + p − 1 \atop r}\right]_{m,f} ≡ \left[{k \atop r}\right]_{m,f} (mod p).

Proof. For k = 1,

\left[{p \atop r}\right]_{m,f} = ∑_{n≥0,n≡r (mod m)} \binom{p}{n}_{f} ≡ ∑_{q≥0,n=pq,n≡q≡r (mod m)} \binom{p}{pq}_{f}

≡ ∑_{q≥0,q≡r (mod m)} f(q) (mod p),

by Theorem 7, and, moreover, \left[{1 \atop r}\right]_{m,f} = ∑_{y≥0,y≡r (mod m)} f(y) (mod p) by definition. For k > 1, the result follows by induction using (10).

Theorem 31. Let f(s) = 0 for almost all s ∈ ℕ. Consider \left[{k \atop 0}\right]_{1,f}, the row sum in row k, or, equivalently, the total number of f-weighted compositions with k parts. Let M = ∑_{s≥0} f(s). Then

\left[{k \atop 0}\right]_{1,f} ≡ M (mod 2)

for all k > 0.

Proof. Consider the equation (∑_{s∈ℕ} f(s)x^{s})^{k} = ∑_{n≥0} \binom{k}{n}_{f}x^{n} over ℤ/pℤ. Plug in x = [1] ∈ ℤ/2ℤ.

Remark 32. Note that the previous theorem generalizes the fact that the number of odd entries in row k in Pascal’s triangle is a multiple of 2.

Example 33. In the triangle in Remark 3, note that M = ∑_{s≥0} f(s) = 5 + 0 + 2 + 1 = 8, so that every row sum in the triangle (except the first) must be even.

5 Applications: Prime criteria

We conclude with two prime criteria for weighted integer compositions, or, equivalently, extended binomial coefficients. Babbage’s prime criterion (see Granville [11] for references) for ordinary binomial coefficients states that an integer n is prime if and only if \binom{n+m}{n} ≡ 1 (mod n) for all integers m satisfying 0 ≤ m ≤ n − 1. The sufficiency of this criterion critically depends on the fact that the entries \binom{p}{r} in the p-th row in Pascal’s triangle are equal to 0 or 1 modulo p and the fact that, for ordinary binomial coefficients, f(s) = 0 for all s > 1. Hence, this criterion is not expected to hold for arbitrary f. Indeed, if n is prime, then, for example, \binom{n+1}{n}_{f} ≡ f(0)f(1) + f(n)f(0) (mod n) by Corollary 11, and then, by repeated application of the corollary and the Vandermonde convolution, \binom{n+2}{n}_{f} ≡ f(0) (f(0)f(1) + ∑_{i≥0} f(i)f(n − i)) (mod n), etc. — and it seems also not obvious how to generalize the criterion.

Conversely, Mann and Shanks’ [16] prime criterion allows a straightforward generalization to weighted integer compositions. We state the criterion and sketch a proof.

Theorem 34. Let f(0) = f(1) = 1. Then, an integer n > 1 is prime if and only if m divides \binom{m}{n−2m}_{f} for all integers m with 0 ≤ 2m ≤ n.

Proof sketch. If n is prime, then by Theorem 19, \binom{m}{n−2m}_{f} ≡ 0 (mod \frac{m}{gcd(m,n−2m)}). Since m < n and n is prime, then gcd(m, n − 2m) = gcd(m, n) = 1.

Conversely, if n is not prime, then, if n is even, \binom{n/2}{0}_{f} = f(0)^{n/2} = 1 and so m = n/2 does not divide \binom{m}{n−2m}_{f}. If n is odd and composite, let p be a prime divisor of n and choose m = (n − p)/2 = pr, for a positive integer r. Thus, \binom{m}{n−2m}_{f} = \binom{pr}{p}_{f}, and by Theorem 20,

\binom{pr}{p}_{f} ≡ \binom{pr}{p} (mod pr) under the outlined conditions on f. Then, Mann and Shanks show

that \binom{pr}{p} ≢ 0 (mod pr).

In an earlier work [8], we have derived all steps of the last theorem via application of (3).

Example 35. Let f(0) = 1, and f(s) = s for all s ≥ 1. Then, as a primality test, e.g., for the integer n = 5, the theorem demands to consider whether 0 | \binom{0}{5}_{f} = 0, 1 | \binom{1}{3}_{f} = 3, and 2 | \binom{2}{1}_{f} = 2 hold true (clearly, the first two of these tests are unnecessary). Similarly, the primality test for n = 6 would be to consider whether 0 | \binom{0}{6}_{f} = 0, 1 | \binom{1}{4}_{f} = 4, 2 | \binom{2}{2}_{f} = 5, and 3 | \binom{3}{0}_{f} = 1 hold true.

As Mann and Shanks [16] point out, the theorem is mainly of theoretical rather than practical interest since to determine whether the involved row numbers divide the respective binomial coefficients may require similarly many computations as in a primality test based on Wilson’s theorem. Also, for practical purposes, one would always want to apply the theorem in the setting of ordinary binomial coefficients (f(s) = 0 for all s > 1).

References

[1] A. K. Agarwal, n-colour compositions, Indian J. Pure Appl. Math. 31 (2000), 1421– 1427.

[2] P. G. Anderson, A. T. Benjamin, and J. A. Rouse, Combinatorial proofs of Fermat’s, Lucas’s, and Wilson’s theorems, Amer. Math. Monthly 112 (2005), 266–268.

[3] C. Babbage, Demonstration of a theorem relating to prime numbers, The Edinburgh Philosophical Journal 1 (1819), 46–49.

[4] C. Banderier and P. Hitczenko, Enumeration and asymptotics of restricted compositions having the same number of parts., Discrete Appl. Math. 160 (2012), 2542–2554.

[5] B. A. Bodarenko, Generalized Pascal triangles and pyramids. English translation published by Fibonacci Association, Santa Clara Univ., Santa Clara, CA, (1993).

[6] R. C. Bollinger and C. L. Burchard, Lucas’s theorem and some related results for extended Pascal triangles., Amer. Math. Monthly 97 (1990), 198–204.

[7] S. Eger, Restricted weighted integer compositions and extended binomial coefficients, J. Integer Seq. 16 (2013), Article 13.1.3.

[8] S. Eger, A proof of the Mann-Shanks primality criterion conjecture for extended binomial coefficients, Integers 14 (2014), A60.

[9] S. Eger, Identities for partial Bell polynomials derived from identities for weighted integer compositions, Aequationes Math. (2015), to appear.

[10] N. E. Fahssi, Polynomial triangles revisited. preprint, http://arxiv.org/abs/1202.0228.

[11] A. Granville, Arithmetic properties of binomial coefficients I: Binomial coefficients modulo prime powers, In Canadian Mathematical Society Conference Proceedings, Vol. 20, pp. 253–275, 1997.

[12] Y.-H. Guo, Some n-color compositions, J. Integer Seq. 15 (2012), Article 12.1.2.

[13] S. Heubach and T. Mansour, Compositions of n with parts in a set., Congr. Numer. 168 (2004), 127–143.

[14] V. E. Hoggatt and D. A. Lind, Compositions and Fibonacci numbers, Fibonacci Quart. 7 (1969), 253–266.

[15] B. Hopkins, Spotted tilings and n-color compositions, Integers 12B (2012), A6.

[16] H. B. Mann and D. Shanks, A necessary and sufficient condition for primality, and its source, J. Combin. Theory Ser. A. 13 (1972), 131–134.

[17] T. Mansour and M. Shattuck, A statistic on n-color compositions and related sequences, Proc. Indian Acad. Sci. Math. Sci. 124 (2014), 127–140.

[18] T. Mansour, M. Shattuck, and M. C. Wilson, Congruence successions in compositions, Discrete Math. Theor. Comput. Sci. 16 (2014), 327–338.

[19] M. Mihoubi, Some congruences for the partial Bell polynomials., J. Integer Seq. 12 (2009), Article 09.4.1.

[20] A. O. Munagi, Euler-type identities for integer compositions via zig-zag graphs, Integers 12 (2012), A60.

[21] A. O. Munagi and J. A. Sellers, Some inplace identities for integer compositions, to appear in Quaestiones Mathematicae.

[22] G. Narang and A. K. Agarwal, Lattice paths and n-colour compositions., Discrete Math. 308 (2008), 1732–1740.

[23] T. Neuschel, A note on extended binomial coefficients, J. Integer Seq. 17 (2014), Article 14.10.4.

[24] J. Ratsaby, Estimate of the number of restricted integer-partitions, Applicable Analysis and Discrete Mathematics 2 (2008), 222–233.

[25] G. Ricci, Sui coefficienti binomiale e polinomali, Giornale di Matematiche (Battaglini) 69 (1931), 9–12.

[26] N. Robbins, On r-regular compositions, to appear.

[27] B. E. Sagan, Compositions inside a rectangle and unimodality, J. Algebraic Combin. 29 (2009), 405–411.

[28] C. Shapcott, C-color compositions and palindromes., Fibonacci Quart. 50 (2012), 297– 303.

[29] C. Shapcott, New bijections from n-color compositions., Journal of Combinatorics 4 (2013), 373–385.

[30] L. Somer, Congruence relations for k^{th}-order linear recurrences, Fibonacci Quart. 27 (1987), 25–33.

[31] Z.-W. Sun and R. Tauraso, Congruences for sums of binomial coefficients, J. Number Theory 126 (2007), 287–296.

2010 Mathematics Subject Classification: Primary 05A10; Secondary 05A17, 11P83, 11A07. Keywords: integer composition, weighted integer composition, colored integer composition, divisibility, extended binomial coefficient, congruence.

(Concerned with sequences \underline{A007318}, and \underline{A027907}.)

Received September 15 2014; revised version received February 20 2015. Published in Journal of Integer Sequences, March 25 2015.

Return to Journal of Integer Sequences home page.