Use modular arithmetic modulo eight: , , and . The squared difference is consequently congruent to one, giving the remainder
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 aThis 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 givesThus the greatest common divisor is . Back-substitution, as in the extended Euclidean algorithm, givesHence , 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 isBoxes 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 givesThe 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
There are currently no matching articles.