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
n is progressive if n = qd + r where q, d, r form a geometric sequence with q > d > r >= 0. Parametrization: n = a^3bc^2 + b^2c with gcd(a,b)=1, a>b>=1, c>=1. We enumerate the admissible parameter triples, test each generated value for being a square, and sum the distinct progressive squares that satisfy the bound.
Pseudocode
INPUT: N = 10^12
OUTPUT: Sum of all progressive perfect squares below N
S <- empty set
FOR a = 2, 3, ..., floor(N^{1/3}):
FOR b = 1, 2, ..., a - 1:
IF gcd(a, b) != 1 THEN CONTINUE
A <- a^3 * b
IF A >= N THEN BREAK
FOR c = 1, 2, ...:
n <- A * c^2 + b^2 * c
IF n >= N THEN BREAK
s <- floor(sqrt(n))
IF s^2 = n THEN S <- S union {n}
RETURN sum of all elements in S
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
answer = sum(progressive_squares)
print(answer)