01Parity, divisibility, and modular arithmeticwarm upNew
How many different strings use exactly three 2s and two 5s?
02Parity, divisibility, and modular arithmeticwarm upNew
Among eight people, how many unordered pairs are there?
Core idea
Divisor pairing makes squares the only integers with an odd number of positive divisors. Prime-factor counts explain trailing zeros. Parity and modular arithmetic retain the part of an integer calculation that matters for the constraint.
Worked example
How many trailing decimal zeros does 30! have?
Let Z(n) be the number of trailing zeros of n!. Each zero comes from a factor ; factors of 5 are the limiting supply. Multiples of contribute an additional factor of 5 at level . The floor symbols mean round down, and terms become zero once . Here .
More practice
Solve these questions here. More practice counts separately from lesson completion.
0 / 12 solved
100 Lights
Practice
1416Parity, divisibility, and modular arithmeticcoreNew
There are 100 light bulbs in a room, each initially off and with its switch by its side. The first person enters and flips every switch. The second person enters and flips every other switch. The third person enters and flips every third switch. This process continues until the 100-th person flips every 100-th switch, or the last switch. How many lights are on?
Balls in Cups
Practice
1478Parity, divisibility, and modular arithmeticcoreNew
You have 10 balls and 3 cups. You may nest cups, counting any cup placed inside another as one item for the outer cup; only items directly inside a cup are counted. Arrange the balls and cups so that each cup contains an odd number of items.
Fruit Magic
Practice
03Parity, divisibility, and modular arithmeticcoreNew
An island has 13 red, 15 green, and 17 blue chameleons. Whenever two of different colors meet, both become the third color.
Least Multiple of 15
Practice
1434Parity, divisibility, and modular arithmeticcoreNew
What is the least positive multiple of 15 whose digits consist of 1's and 0's only?
Lightbulbs
Practice
1467Parity, divisibility, and modular arithmeticcoreNew
Imagine a science experiment involving 500 light bulbs, each numbered from 1 to 500, and all initially switched on. A scientist introduces a process where, for every natural number 'n' from 1 to 500, he toggles (switches the state) of all light bulbs whose numbers are divisible by 'n'. So, during the first pass, every bulb is toggled since 1 is a factor of all numbers. During the second pass, the scientist toggles every second bulb (those with numbers that are multiples of 2), and so on, until he reaches the 500th pass.
The question is: after going through this entire process, how many of the 500 light bulbs will remain illuminated?
Number 50
Practice
1438Parity, divisibility, and modular arithmeticcoreNew
How many 10 digit numbers are there whose digits are prime and whose product of its digits is exactly 100000?
Trailing Zero's
Practice
1474Parity, divisibility, and modular arithmeticcoreNew
Determine the number of trailing zeros in the value of 1000 factorial (1000!).
1397Parity, divisibility, and modular arithmeticcoreNew
Two urns have the same positive total number of balls, with some black and some white in each. Draw n>3 balls with replacement from each urn. Find the number of draws and the compositions so that the chance of all whites from the first equals the chance of either all whites or all blacks from the second.
1270Parity, divisibility, and modular arithmeticcoreNew
Choose an integer uniformly from 1 through 1012. What is the probability its cube ends in 11?
Found a mistake in this lesson?
10=2⋅5
5k
k
5k>n
n=30
Z(n)=k=1∑∞⌊5kn⌋.
It has seven. Each zero needs a factor two and a factor five, and the factorial supplies more twos. Multiples of five contribute six fives, and the multiple of 25 contributes one extra: ⌊30/5⌋+⌊30/25⌋=6+1=7.
Methods and variations
A. Specify what an odd count includes
Parity applies to the objects actually counted. In nested cups, each contained cup counts as one direct item, so the sum of direct-content counts equals the number of balls plus the number of nesting links.
Adding odd counts is a statement about precisely specified objects. Modulo two, every odd count contributes one, so the sum of m odd counts has the same parity as m:
a1+⋯+am≡m(mod2)if every ai is odd.
A nesting link can contribute an extra directly contained item even though it creates no extra ball. Counting all appearances of a ball inside larger containers is yet another convention. State which convention the puzzle uses, express the total under that convention, and only then apply parity. An apparent contradiction often comes from silently changing what “inside” means.
Practice
03Parity, divisibility, and modular arithmeticcoreNew
Six balls must occupy three cups. Cups may contain other cups, and a directly contained cup counts as one item. Give each cup an odd number of direct items.
04Parity, divisibility, and modular arithmetichardNew
Could six balls be split among three non-nested cups with an odd number of balls in every cup?
B. Pair divisors before counting toggles
Divisors of n pair as d and n/d. Only a square has one self-pair, so only squares are toggled an odd number of times; whether they end on depends on the initial state.
Figure1 The nonsquare 30 has four pairs of distinct divisors and therefore eight divisors. For 36, the four ordinary pairs leave the divisor 6 paired with itself, giving nine divisors. A self-pair occurs exactly when d^2^ = n, which explains why only squares have odd divisor counts.
The pairing map d↦n/d sends every positive divisor to another positive divisor and applying it twice returns the original divisor. Distinct pairs therefore contribute an even number of divisors. A divisor remains unpaired only when d=n/d, or d2=n.
In a toggling puzzle, two toggles undo one another. If position n is toggled once for each divisor of n, its final state differs from its initial state exactly when n is a square. Among positions 1 through M, there are ⌊M⌋ such positions. This counts changed states; whether “changed” means on or off depends on how the switches started.
Practice
05Parity, divisibility, and modular arithmeticcoreNew
Bulbs 1 through 36 start off. Bulb j is toggled once for each positive divisor of j. How many end on?
06Parity, divisibility, and modular arithmeticcoreNew
A locker changes status once for every visit from a worker numbered by a positive divisor of its index. Which indices from 1 through 16 change status overall? Give them in increasing order.
07Parity, divisibility, and modular arithmetichardNew
Bulbs 1 through 36 start on. Each bulb is toggled once for every positive divisor of its index. How many finish on?
C. Count the limiting prime factors of a base
In n!, a prime p occurs vp(n!)=∑j≥1⌊n/pj⌋ times. Multiples of p2 contribute a second copy and must be counted again.
If the numerical base is ∏ipiai, its trailing-zero count is mini⌊vpi(n!)/. Decimal zeros are limited by fives, not by numbers whose last digit is five.
Let vp(m) count the copies of prime p in the factorization of m. Each multiple of p contributes at least one copy, each multiple of p2 contributes another, and so on. Counting these layers gives
vp(n!)=⌊pn⌋+⌊p2n⌋+⋯.
The sum is effectively finite. For a base b=p1a1⋯prar, each trailing zero consumes one complete package of ai copies of every prime pi. The limiting ingredient determines the number of packages:
Zb(n!)=1≤i≤rmin⌊aivpi(n!)⌋.
Taking a sum instead of a minimum would let surplus copies of one prime substitute for a missing different prime. They cannot. For decimal notation, each zero requires both a two and a five.
Practice
08Parity, divisibility, and modular arithmeticcoreNew
How many trailing zeros does 50! have in decimal?
09Parity, divisibility, and modular arithmeticcoreNew
How many complete packages of twelve prime-factor units can be removed multiplicatively from 12!? Equivalently, find the largest k for which 12k divides 12!.
10Parity, divisibility, and modular arithmetichardNew
A solver counts twenty-five multiples of five in 125! and reports twenty-five trailing zeros. Correct the count.
D. Use decimal constraints and factorization before arranging digits
Since 10≡1(mod3), divisibility by three is determined by the digit sum; divisibility by five fixes the last digit as zero or five. Prove a minimum by combining a necessary length bound with a construction.
Prime decimal digits are 2,3,5,7. Factor a prescribed product to determine their multiplicities, then count their orders; one is not prime.
A decimal number with digits dj is ∑jdj10j. Since every power of ten is one modulo three, the number and its digit sum have the same remainder. Modulo five, all terms except the units digit disappear. These rules follow from place value rather than from a special property of a memorized list of digits.
For a prescribed product of prime digits, unique factorization determines how many 2s, 3s, 5s and 7s occur. It does not determine their order. Solve the multiplicity constraint first, then use the repeated-object permutation count. To prove a smallest possible number, first rule out all shorter lengths; among valid strings of the minimum length, compare the most significant differing digit.
Practice
11Parity, divisibility, and modular arithmeticcoreNew
Find the smallest positive decimal number containing only zeros and ones that is divisible by 15.
12Parity, divisibility, and modular arithmeticcoreNew
A machine accepts a positive decimal label containing only zeros and ones. The label must be divisible by six. What is the smallest accepted label?
13Parity, divisibility, and modular arithmetichardNew
A four-digit number uses only zeros and ones and has a digit sum divisible by three. Must it be divisible by 15?
E. Reduce a decimal calculation to the needed remainder
The decimal expansion gives the digit sum modulo 9 and the alternating digit sum modulo 11 because 10≡1(mod9) and 10≡−1(mod11). For a last-two-digit constraint, first solve for the units digit, then write x=a+10b and expand.
Cancelling a common factor from a divisibility statement changes the modulus: 10u≡0(mod100) means u≡0(mod10).
The same expansion explains the two common digit tests:
For last-two-digit questions, work modulo 100 and write a candidate as x=a+10b, where a is its units digit. In a square, for example, x2≡a2+20ab(mod100) because the 100b2 term vanishes. This separates a units constraint from a tens constraint.
Cancellation needs care. In cu≡cv(modm), division by c changes the modulus to m/gcd(c,m). Keeping modulus m is valid only when c is invertible modulo m. Ordinary division and modular division obey different conditions.
Practice
14Parity, divisibility, and modular arithmeticcoreNew
Which residue x from 0 through 99 satisfies x3≡11(mod100)?
15Parity, divisibility, and modular arithmetichardNew
A solver replaces 30b≡10(mod100) by 3b≡1(mod100). What is wrong?
F. State the integer hypothesis being contradicted
If 2=a/b in lowest terms, a2=2b2 forces both a and b even, contradicting the reduced form. Finite decimal inspection cannot prove irrationality.
In the optional urn extension, equal denominators turn the equality of draw probabilities into zn=xn+yn. With positive integer x,y,z and integer n≥3, Fermat’s Last Theorem rules it out; its proof is outside this course.
The contradiction for 2 uses a reduced fraction, not a decimal approximation. If a2 is even, a must be even: an odd number has an odd square. Write a=2c. Substitution into a2=2b2 then gives b2=2c2, forcing b even too. Both share a factor two, contrary to choosing the fraction in lowest terms.
In an impossibility argument, list every hypothesis needed by the theorem: positivity, integrality, exponent range and allowed operations. A result about positive integers need not hold for zero, negative values or real numbers. A numerical search can find a counterexample, but failing to find one over a finite range does not prove there are none.
Practice
16Parity, divisibility, and modular arithmeticcoreNew
Prove that 2 is irrational.
Lesson check
17Parity, divisibility, and modular arithmeticcoreNew
How many trailing zeros does 10! have when written in base twelve?
18Parity, divisibility, and modular arithmeticcoreNew
Bulbs 1 through 25 start off and bulb j is toggled once for each positive divisor of j. List the five indices that finish on in increasing order.
19Parity, divisibility, and modular arithmeticcoreNew
Find the number of trailing zeros in 100!.
20Parity, divisibility, and modular arithmeticcoreNew
A six-digit serial number uses only prime decimal digits. The product of its digits is 1000. How many serial numbers are possible?