Sum of Symmetric Remainders over All Ordered Pairs

Define:

C(i, j) = (i mod j) + (j mod i).

Given a positive integer n, compute the sum over all ordered pairs satisfying 1 <= i <= n and 1 <= j <= n:

S = Σ(i=1..n) Σ(j=1..n) C(i, j).

R...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: