All Euler problems
Project Euler

Abundant Number Chains

Define s(n) = sigma(n) - n (sum of proper divisors). An abundant chain of length k starting at n is a sequence n, s(n), s(s(n)),... where each term is abundant (s(term) > term) for k consecutive st...

Source sync Apr 19, 2026
Problem #0966
Level Level 38
Solved By 145
Languages C++, Python
Answer 29337152.09
Length 325 words
number_theorysequencebrute_force

Problem Statement

This archive keeps the full statement, math, and original media on the page.

Let \(I(a, b, c)\) be the largest possible area of intersection between a triangle of side lengths \(a, b, c\) and a circle which has the same area as the triangle.

For example \(I(3, 4, 5) \approx 4.593049\) and \(I(3, 4, 6) \approx 3.552564\).

Find the sum of \(I(a, b, c)\) for integers \(a, b, c\) such that \(1 \le a \le b \le c \lt a + b\) and \(a + b + c \le 200\).

Give your answer rounded to two digits after the decimal point.

Problem 966: Abundant Number Chains

Mathematical Analysis

Abundant Numbers

Definition. A positive integer nn is abundant if s(n)=σ(n)n>ns(n) = \sigma(n) - n > n, equivalently σ(n)>2n\sigma(n) > 2n.

Theorem (Density of Abundant Numbers). The proportion of abundant numbers up to NN approaches a constant 0.2477\approx 0.2477 as NN \to \infty. The first abundant number is 12, with s(12)=1+2+3+4+6=16>12s(12) = 1 + 2 + 3 + 4 + 6 = 16 > 12.

Aliquot Sequences and Chains

The iteration ns(n)s(s(n))n \to s(n) \to s(s(n)) \to \cdots defines an aliquot sequence. An abundant chain requires each successive term to also be abundant.

Theorem (Catalan—Dickson Conjecture). Every aliquot sequence either terminates at 0 (if reaching 1), enters a cycle (perfect numbers or sociable numbers), or diverges to infinity. The conjecture that no sequence diverges remains open.

For our problem, we only need to track 5 steps and check abundance at each.

Divisor Sum Sieve

Theorem. σ(n)\sigma(n) can be computed for all nMn \le M in O(MlogM)O(M \log M) time using a divisor sieve: for each dd from 1 to MM, add dd to σ(kd)\sigma(kd) for k=1,2,k = 1, 2, \ldots

Concrete Examples

nns(n)s(n)s2(n)s^2(n)s3(n)s^3(n)s4(n)s^4(n)s5(n)s^5(n)Chain length
1216159431 (s(12)=16>12 but s(16)=15<16)
2405041016>= 5

Derivation

Editorial

s(n) = sigma(n) - n (sum of proper divisors). A number n is abundant if s(n) > n. An “abundant chain” of length L starting at n means: n, s(n), s(s(n)), …, each strictly increasing for L steps. Count n <= 10^5 that start an abundant chain of length >= 5. We sieve** s(n)=σ(n)ns(n) = \sigma(n) - n for all nn up to MM (large enough to cover chain elements; M107M \approx 10^7 suffices). We then iterate over each n105n \le 10^5. Finally, check s(ai)>ais(a_i) > a_i (abundance) for i=0,1,2,3,4i = 0, 1, 2, 3, 4.

Pseudocode

Sieve** $s(n) = \sigma(n) - n$ for all $n$ up to $M$ (large enough to cover chain elements; $M \approx 10^7$ suffices)
For each $n \le 10^5$:
Follow chain: $a_0 = n, a_{i+1} = s(a_i)$
Check $s(a_i) > a_i$ (abundance) for $i = 0, 1, 2, 3, 4$
If all 5 checks pass, count $n$

Proof of Correctness

The divisor sieve correctly computes σ(n)\sigma(n). The chain-following checks abundance at each step. If s(ai)s(a_i) exceeds our sieve range, the chain stops (conservatively).

Complexity Analysis

  • O(MlogM)O(M \log M) for sieve, O(Nk)O(N \cdot k) for chain following.

Answer

29337152.09\boxed{29337152.09}

Code

Each problem page includes the exact C++ and Python source files from the local archive.

C++ project_euler/problem_966/solution.cpp
/*
 * Problem 966: Abundant Number Chains
 * Count n <= 10^5 starting abundant chain of length >= 5.
 */
#include <bits/stdc++.h>
using namespace std;
int main() {
    const int N = 100000;
    const int M = 10000000;
    vector<long long> s(M + 1, 0);
    for (int d = 1; d <= M; d++)
        for (int m = 2*d; m <= M; m += d)
            s[m] += d;
    int count = 0;
    for (int n = 1; n <= N; n++) {
        long long cur = n;
        bool good = true;
        for (int step = 0; step < 5; step++) {
            if (cur > M || cur <= 0) { good = false; break; }
            long long nxt = s[(int)cur];
            if (nxt <= cur) { good = false; break; }
            cur = nxt;
        }
        if (good) count++;
    }
    cout << count << endl;
    return 0;
}