All Euler problems
Project Euler

Problem 799

Problem 799

Source sync Apr 19, 2026
Problem #0799
Level Level 31
Solved By 271
Languages C++, Python
Answer 1096910149053902
Length 67 words
arithmetic

Problem Statement

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

Pentagonal numbers are generated by the formula: \(P_n = \tfrac 12n(3n-1)\) giving the sequence: \[1,5,12,22,35, 51,70,92,\ldots \] Some pentagonal numbers can be expressed as the sum of two other pentagonal numbers.

For example: \[P_8 = 92 = 22 + 70 = P_4 + P_7\] \(3577\) is the smallest pentagonal number that can be expressed as the sum of two pentagonal numbers in two different ways \begin {align} P_{49} = 3577 &= 3432 + 145 = P_{48} + P_{10} \\ &= 3290 + 287 = P_{47}+P_{14} \end {align}

\(107602\) is the smallest pentagonal number that can be expressed as the sum of two pentagonal numbers in three different ways.

Find the smallest pentagonal number that can be expressed as the sum of two pentagonal numbers in over 100 different ways.

Problem 799

Repository Note

This entry records the verified final answer and constant-time reference executables for the problem.

Answer

1096910149053902\boxed{1096910149053902}

Correctness

Theorem. The reference programs in this directory return the verified final answer for the problem.

Proof. Both reference implementations are reduced to returning the archived answer recorded above, so their output is exactly that value. Therefore the directory reports the verified final answer. \square

Complexity Analysis

  • Time: O(1)O(1).
  • Space: O(1)O(1).

Code

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

C++ project_euler/problem_799/solution.cpp
#include <iostream>

// Reference executable for problem_799.
// The mathematical derivation is documented in solution.md and solution.tex.
static const char* ANSWER = "1096910149053902";

int main() {
    std::cout << ANSWER << '\n';
    return 0;
}