Use modular arithmetic modulo eight: , , and . The squared difference is consequently congruent to one, giving the remainder
Modulo seven, and . Therefore . The remainder is , using modular exponentiation.
For integers not both zero, replace them first by their absolute values, then repeat integer division:
while b != 0:
    (a,b) := (b, a mod b)
return a
This is the Euclidean algorithm. Its loop invariant is that equals the original greatest common divisor. When , the new remainder lies in , so is a strictly decreasing nonnegative loop variant. At termination, , proving correctness, including the case where one original input is zero.
The Euclidean algorithm gives
Thus the greatest common divisor is . Back-substitution, as in the extended Euclidean algorithm, gives
Hence , with and .
For one colour, the box occupancies form a weak composition of into nonnegative parts. For , stars and bars gives choices. The three colours' occupancies can be selected independently, so the number is
Boxes are labelled, while equal-colour balls contribute only occupancy counts; no extra factorial for permuting such balls is appropriate.
There are unrestricted placements, since one colour has occupancy vectors. For any specified empty box, the two remaining boxes admit placements. For any specified pair of empty boxes, the one remaining box admits one placement. All three boxes cannot be empty.
The inclusion-exclusion principle therefore gives
The empty-box events are not disjoint events, so subtracting their counts without restoring their pairwise overlaps would be incorrect.
The base cases are , and . Suppose a counterexample exists and choose the least integer failing the claim. It is not one of these base cases, so and .
Minimality supplies nonnegative integers with . Then , a contradiction. This proof by minimal counterexample establishes the claim. Three consecutive base cases are needed because the reduction subtracts three.

Articles by others on the same topic (0)

There are currently no matching articles.