Shifted Multiples
For a positive integer n with leading digit d_1 and remaining digits forming number m, define shift(n) = 10m + d_1 (cyclic left shift of digits). Let r(n) = n mod shift(n). Find S(N) = sum_(n=1)^N...
Problem Statement
This archive keeps the full statement, math, and original media on the page.
For a positive integer $n$, let $s(n)$ be the integer obtained be shifting the leftmost digit of the decimal representation of $n$ to the rightmost position. For example, $s(142857) = 142864$ and $s(10) = 1$.
For a positive rational number $r$, we define $N(r)$ as the smallest positive integer $n$ such that $s(n) = r \cdot n$.
If no such integer exists, then $N(r)$ is defined as zero.
For example, $N(3) = 142857$, $N\left(\frac{1}{10}\right) = 10$ and $n(2) = 0$.
Let $T(M)$ be the sum of $N(u^3/v^3)$ where $(u, v)$ ranges over all ordered pairs of coprime positive integes not exeeding $M$.
For example, $T(3) \equiv 26242973 \pmod{10^9 + 7}$.
Find $T(200)$. Give your answer modulo $10^9 + 7$.
Problem 805: Shifted Multiples
Mathematical Analysis
For a -digit number with leading digit and tail : and .
The remainder . We can express in terms of :
Derivation
Let . Then and .
So . Thus , giving , i.e., .
We can write directly by computing the quotient and .
For efficient summation, we group by — digit length and leading digit — and sum over all valid values.
Proof of Correctness
The digit shift is well-defined for all multi-digit numbers. For single-digit numbers, , so . The grouping by digit length ensures complete coverage without overlap.
Correctness
Theorem. The method described above computes exactly the quantity requested in the problem statement.
Proof. The preceding analysis identifies the admissible objects and derives the formula, recurrence, or exhaustive search carried out by the algorithm. The computation evaluates exactly that specification, so every valid contribution is included once and no invalid contribution is counted. Therefore the returned value is the required answer.
Complexity Analysis
Direct computation: . With grouping by digit length: which can be sub-linear for structured summation.
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N = 10000, total = 0;
for (long long n = 10; n <= N; n++) {
string s = to_string(n);
string shifted_s = s.substr(1) + s[0];
long long shifted = stoll(shifted_s);
if (shifted > 0) total += n % shifted;
}
cout << total << endl;
return 0;
}
"""
Problem 805: Shifted Multiples
For a positive integer $n$ with leading digit $d_1$ and remaining digits forming number $m$, define $\text{shift}(n) = 10m + d_1$ (cyclic left shift of digits). Let $r(n) = n \bmod \text{shift}(n)$. Find $S(N) = \sum_{n=1}^{N} r(n)$.
"""
def solve(N=10000):
"""Sum of n mod shift(n) for n = 1 to N."""
total = 0
for n in range(1, N + 1):
s = str(n)
if len(s) == 1:
continue # shift(n) = n, remainder = 0
shifted = int(s[1:] + s[0])
if shifted == 0:
continue
total += n % shifted
return total
answer = solve()
print(answer)