Lesson goal: The integer geometric progression puzzle

Previous: Digit sums and divisibility by 11 | Home | Next: Minimum digit quotient

In the 1971 MAA High School Mathematics Contest (Problem #36), students tackled this clever algebra puzzle:

A sequence of five positive integers, each less than 100, has the property that the first three terms are in geometric progression and the last three are also in geometric progression. If the common ratio is the same in both cases and the sum of the five terms is 211, find the sum of those terms which are perfect squares.

A geometric sequence has consecutive terms related by a constant ratio $r$: $$a, \quad a \cdot r, \quad a \cdot r^2, \quad a \cdot r^3, \quad a \cdot r^4$$ Since the problem states that the first three terms and the last three terms have the same ratio $r$, the entire sequence is a 5-term geometric progression!

Because all five terms are integers, the ratio $r$ must be a rational number $\frac{p}{q}$ in lowest terms (with $\gcd(p, q) = 1$). For the fifth term $a \cdot \left(\frac{p}{q}\right)^4 = a \frac{p^4}{q^4}$ to be an integer, the starting term $a$ must be divisible by $q^4$.

Writing $a = k \cdot q^4$ for some positive integer $k \ge 1$, the five terms are: $$T_1 = k q^4, \quad T_2 = k q^3 p, \quad T_3 = k q^2 p^2, \quad T_4 = k q p^3, \quad T_5 = k p^4$$ Their sum is: $$k \cdot (q^4 + q^3 p + q^2 p^2 + q p^3 + p^4) = 211$$ Notice that 211 is a prime number! Since $k$ must divide 211 and $q^4 + \dots \ge 5$, we must have $k = 1$.

In this lesson, we write a program to search all possible ratios $\frac{p}{q}$, generate candidate sequences whose terms are less than 100, find the sequence that sums to 211, and calculate the sum of its perfect square terms!
function is_square(n)
root = math.floor(math.sqrt(n) + 0.5)

return root * root == n

end

terms = {16, 24, 36, 54, 81}

sum_squares = 0

for i, v in ipairs(terms) do

if is_square(v) then sum_squares = sum_squares + v end

end
Move the mouse over a dotted box for more information.

The five terms are $16, 24, 36, 54, 81$. Their sum is $16 + 24 + 36 + 54 + 81 = 211$. The terms that are perfect squares are $16 = 4^2$, $36 = 6^2$, and $81 = 9^2$. Their sum is $16 + 36 + 81 = 133$!

Now you try. Run the code above to find the sequence and compute the sum of squares ($133$). Then check Example 1 to test another contest variation with a sum of 121!

Type your code here:


See your results here: