Stealthy Numbers
A positive integer N is stealthy if there exist positive integers a, b, c, d such that a b = c d = N and a + b = c + d + 1. For example, 36 = 4 x 9 = 6 x 6 is stealthy since 4 + 9 = 13 = 6 + 6 + 1....
Problem Statement
This archive keeps the full statement, math, and original media on the page.
A positive integer \(N\) is
For example, \(36 = 4\times 9 = 6\times 6\) is stealthy.
You are also given that there are 2851 stealthy numbers not exceeding \(10^6\).
How many stealthy numbers are there that don’t exceed \(10^{14}\)?
Problem 757: Stealthy Numbers
Mathematical Analysis
Key Observation: Bipronic Numbers
A stealthy number can be written as where and .
If we write and , we can use the identity relating factorizations to sums. Consider two factorizations of : with .
Connection to Pronic Numbers
A pronic (oblong) number is a number of the form . The key insight is:
Theorem: A positive integer is stealthy if and only if can be expressed as where both and are pronic numbers (i.e., and for positive integers ).
Proof: If , set:
- , … more carefully:
- , , so
- , , so
- Therefore . QED.
Editorial
Enumerate all products where , and count distinct values using a hash set or sorted merge approach.
For the upper bound on : since , we need , giving .
For each , ranges from to the largest value such that .
Complexity Analysis
- Time: where is the total number of products generated (around ), dominated by sorting/deduplication.
- Space: to store all products.
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(){
long long LIMIT = 100000000000000LL; // 10^14
vector<long long> results;
// x(x+1) * y(y+1) <= LIMIT, with x <= y
// x(x+1) <= sqrt(LIMIT) ~ 10^7
for(long long x = 1; x*(x+1)*(x)*(x+1) <= LIMIT; x++){
long long px = x * (x + 1);
for(long long y = x; ; y++){
long long py = y * (y + 1);
long long val = px * py;
if(val > LIMIT) break;
results.push_back(val);
}
}
sort(results.begin(), results.end());
long long count = unique(results.begin(), results.end()) - results.begin();
cout << count << endl;
return 0;
}
#!/usr/bin/env python3
"""
Project Euler Problem 757: Stealthy Numbers
A number N is stealthy if N = x(x+1)*y(y+1) for positive integers x, y.
Count stealthy numbers <= 10^14.
"""
def solve():
LIMIT = 10**14
results = set()
x = 1
while x * (x + 1) * x * (x + 1) <= LIMIT:
px = x * (x + 1)
y = x
while True:
py = y * (y + 1)
val = px * py
if val > LIMIT:
break
results.add(val)
y += 1
x += 1
print(len(results))
solve()