Investigating Progressive Numbers
A positive integer n is called progressive if, when dividing n by some positive integer d, the quotient q and remainder r satisfy: q, d, r form a geometric sequence (in that order) with q > d > r >...
Problem Statement
This archive keeps the full statement, math, and original media on the page.
A positive integer, \(n\), is divided by \(d\) and the quotient and remainder are \(q\) and \(r\) respectively. In addition \(d\), \(q\), and \(r\) are consecutive positive integer terms in a geometric sequence, but not necessarily in that order.
For example, \(58\) divided by \(6\) has quotient \(9\) and remainder \(4\). It can also be seen that \(4, 6, 9\) are consecutive terms in a geometric sequence (common ratio \(3/2\)).
We will call such numbers, \(n\), progressive.
Some progressive numbers, such as \(9\) and \(10404 = 102^2\), happen to also be perfect squares.
The sum of all progressive perfect squares below one hundred thousand is \(124657\).
Find the sum of all progressive perfect squares below one trillion (\(10^{12}\)).
Problem 141: Investigating Progressive Numbers
Mathematical Development
Definition 1. We call progressive if there exist integers with , , , and (the geometric sequence condition).
Theorem 1 (Exclusion of ). No progressive number has .
Proof. If , then , so . But requires , a contradiction.
Theorem 2 (Parametrization). Every progressive number with admits a unique representation
where are positive integers satisfying , , and . The corresponding division parameters are , , .
Proof. Suppose with and .
Step 1 (Reduction to coprime form). Let and write , where . From :
Since and is a positive integer, we require . Write for some positive integer .
Step 2 (Explicit formulas). Substituting :
Step 3 (Relabeling). Setting and yields , , with .
Step 4 (Ordering verification). We verify :
- , which holds by construction since in the original problem.
- , also satisfied.
Step 5 (Formula for ).
Step 6 (Uniqueness). Given , the ratio in lowest terms is uniquely determined, and follows. Conversely, distinct triples yield distinct triples since , , are injective in .
Lemma 1 (Search bounds). The following bounds hold:
- where .
- For fixed : .
Proof. Since , the constraint forces . For fixed with , gives .
Remark. Different triples may produce the same value of (though different triples). Hence we collect progressive numbers in a set to avoid double-counting before checking for perfect squares.
Editorial
The parametrization from the mathematical development turns the problem into a direct enumeration over coprime pairs with and a scaling parameter . For each such triple, the candidate progressive number is
The leading term already controls the size, so once it exceeds the limit there is no reason to continue with larger , and once exceeds the limit there is no reason to continue with larger for that fixed .
That leaves a clean search: walk through all admissible , skip non-coprime pairs, then grow until the bound is crossed. Every produced value is checked with an integer square root, and any perfect square is inserted into a set. The set matters because distinct parameter triples can lead to the same progressive number, and the problem asks for each qualifying square only once.
Pseudocode
Set the limit to $10^{12}$ and create an empty set of progressive squares.
For each integer $a \ge 2$ while $a^3$ is still below the limit:
Try every $b$ from 1 up to $a-1$.
Ignore the pair unless $\gcd(a,b)=1$.
Compute the fixed factor $a^3b$.
If this factor already reaches the limit, stop increasing $b$ for this $a$.
Starting from $c=1$, generate
$$
n=a^3bc^2+b^2c.
$$
If $n$ reaches the limit, stop increasing $c$.
Otherwise compute the integer square root of $n$.
When the square root squares back to $n$, record $n$ in the set.
After all triples have been examined, return the sum of the distinct values in the set.
Complexity Analysis
Time. The outer loop over runs iterations. For each , the loop over runs at most iterations, reduced by the coprimality filter to on average. The innermost loop over runs iterations. The total work is bounded by:
The inner sum is and the resulting series converges, giving .
Space. where is the number of progressive perfect squares found (empirically very small).
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() {
// Find sum of all progressive perfect squares below 10^12
// n = a^3 * b * c^2 + b^2 * c, with gcd(a,b)=1, a>b>=1, c>=1
// Check if n is a perfect square
long long LIMIT = 1000000000000LL; // 10^12
set<long long> squares;
for (long long a = 2; a * a * a < LIMIT; a++) {
for (long long b = 1; b < a; b++) {
if (__gcd(a, b) != 1) continue;
// n = a^3*b*c^2 + b^2*c
// For c=1: n = a^3*b + b^2
long long a3b = a * a * a * b;
if (a3b >= LIMIT) break;
for (long long c = 1; ; c++) {
long long n = a3b * c * c + b * b * c;
if (n >= LIMIT) break;
long long s = (long long)sqrt((double)n);
// Check around s due to floating point
for (long long t = max(1LL, s - 2); t <= s + 2; t++) {
if (t * t == n) {
squares.insert(n);
break;
}
}
}
}
}
long long ans = 0;
for (long long x : squares) ans += x;
cout << ans << endl;
return 0;
}
"""
Problem 141: Investigating Progressive Numbers
Find the sum of all progressive perfect squares below 10^12.
n is progressive if n = q*d + r where q, d, r form a geometric sequence
with q > d > r >= 0.
Parametrization: n = a^3*b*c^2 + b^2*c with gcd(a,b)=1, a>b>=1, c>=1.
"""
from math import gcd, isqrt
def solve():
LIMIT = 10**12
progressive_squares = set()
a = 2
while a * a * a < LIMIT:
for b in range(1, a):
if gcd(a, b) != 1:
continue
a3b = a**3 * b
if a3b >= LIMIT:
break
c = 1
while True:
n = a3b * c * c + b * b * c
if n >= LIMIT:
break
s = isqrt(n)
if s * s == n:
progressive_squares.add(n)
c += 1
a += 1
return sum(progressive_squares)
if __name__ == "__main__":
answer = solve()
assert answer == 878454337159
print(answer)