Planetary Gears
Analyze gear ratios in a planetary gear system and find specific configurations.
Problem Statement
This archive keeps the full statement, math, and original media on the page.
A circle \(C\) of circumference \(c\) centimetres has a smaller circle \(S\) of circumference \(s\) centimetres lying off-centre within it. Four other distinct circles, which we call "planets", with circumferences \(p\), \(p\), \(q\), \(q\) centimetres respectively (\(p < q\)), are inscribed within \(C\) but outside \(S\), with each planet touching both \(C\) and \(S\) tangentially. The planets are permitted to overlap one another, but the boundaries of \(S\) and \(C\) must be at least 1cm apart at their closest point.
Now suppose that these circles are actually gears with perfectly meshing teeth at a pitch of 1cm. \(C\) is an internal gear with teeth on the inside. We require that \(c\), \(s\), \(p\), \(q\) are all integers (as they are the numbers of teeth), and we further stipulate that any gear must have at least 5 teeth.
Note that "perfectly meshing" means that as the gears rotate, the ratio between their angular velocities remains constant, and the teeth of one gear perfectly align with the groves of the other gear and vice versa. Only for certain gear sizes and positions will it be possible for \(S\) and \(C\) each to mesh perfectly with all the planets. Arrangements where not all gears mesh perfectly are not valid.
Define \(g(c,s,p,q)\) to be the number of such gear arrangements for given values of \(c\), \(s\), \(p\), \(q\): it turns out that this is finite as only certain discrete arrangements are possible satisfying the above conditions. For example, \(g(16,5,5,6)=9\).

Let \(G(n) = \displaystyle \sum _{s+p+q\le n} g(s+p+q,s,p,q)\) where the sum only includes cases with \(p < q\), \(p\ge 5\), and \(s\ge 5\), all integers. You are given that \(G(16)=9\) and \(G(20)=205\).
Find \(G(500)\).
Problem 620: Planetary Gears
Mathematical Analysis
The gear ratio of a planetary system with sun gear , ring gear , and planet gears is .
Derivation
The solution follows from the mathematical analysis above.
Correctness
Theorem. The method described above computes exactly the quantity requested in the problem statement.
Proof. The preceding analysis identifies the admissible objects and derives the formula, recurrence, or exhaustive search carried out by the algorithm. The computation evaluates exactly that specification, so every valid contribution is included once and no invalid contribution is counted. Therefore the returned value is the required answer.
Complexity Analysis
- Time: See implementation.
- Space: See implementation.
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
int main() {
int max_teeth = 100;
int count = 0;
for (int s = 1; s <= max_teeth; s++) {
for (int r = s + 1; r <= max_teeth; r++) {
if ((r - s) % 2 != 0) continue;
int p = (r - s) / 2;
if (p < 1) continue;
if (r % s == 0) { // integer ratio
count++;
}
}
}
cout << "Integer ratio configs: " << count << endl;
return 0;
}
"""
Problem 620: Planetary Gears
Analyze gear ratios in planetary gear systems.
"""
def planetary_gear_ratio(sun_teeth, ring_teeth):
"""Gear ratio of a planetary gear system.
With fixed ring: ratio = 1 + ring/sun
With fixed carrier: ratio = -ring/sun
With fixed sun: ratio = 1 + sun/ring ... but inverted
"""
return 1 + ring_teeth / sun_teeth
def find_integer_ratios(max_teeth=100):
"""Find sun/ring combinations giving integer gear ratios."""
results = []
for s in range(1, max_teeth + 1):
for r in range(s + 1, max_teeth + 1):
# Planet teeth = (r - s) / 2, must be positive integer
if (r - s) % 2 != 0:
continue
p = (r - s) // 2
if p < 1:
continue
ratio = 1 + r / s
if abs(ratio - round(ratio)) < 1e-10:
results.append((s, p, r, int(round(ratio))))
return results
results = find_integer_ratios(100)
print(f"Found {len(results)} integer-ratio planetary gear configs")
for s, p, r, ratio in results[:15]:
print(f" Sun={s}, Planet={p}, Ring={r}, Ratio={ratio}")