All Euler problems
Project Euler

Problem 760

Problem 760

Source sync Apr 19, 2026
Problem #0760
Level Level 23
Solved By 513
Languages C++, Python
Answer 172747503
Length 67 words
arithmetic

Problem Statement

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

Define \[\displaystyle g(m,n) = (m\oplus n)+(m\vee n)+(m\wedge n)\] where \(\oplus , \vee , \wedge \) are the bitwise XOR, OR and AND operator respectively.

Also set \[\displaystyle G(N) = \sum _{n=0}^N\sum _{k=0}^n g(k,n-k)\] For example, \(G(10) = 754\) and \(G(10^2) = 583766\).

Find \(G(10^{18})\). Give your answer modulo \(1\,000\,000\,007\).

Problem 760

Repository Note

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

Answer

172747503\boxed{172747503}

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

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

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