All Euler problems
Project Euler

Problem 785

Problem 785

Source sync Apr 19, 2026
Problem #0785
Level Level 34
Solved By 235
Languages C++, Python
Answer 29526986315080920
Length 67 words
arithmetic

Problem Statement

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

Consider the following Diophantine equation: \[15 (x^2 + y^2 + z^2) = 34 (xy + yz + zx)\] where \(x\), \(y\) and \(z\) are positive integers.

Let \(S(N)\) be the sum of all solutions, \((x,y,z)\), of this equation such that, \(1 \le x \le y \le z \le N\) and \(\gcd (x, y, z) = 1\).

For \(N = 10^2\), there are three such solutions - \((1, 7, 16), (8, 9, 39), (11, 21, 72)\). So \(S(10^2) = 184\).

Find \(S(10^9)\).

Problem 785

Repository Note

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

Answer

29526986315080920\boxed{29526986315080920}

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_785/solution.cpp
#include <iostream>

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

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