← RoseCode

ROSECODE 478

Counting modulo pairs

liuguangxi · Math ·

Let f(m) denote the number of integer pairs (x,m) such that there exists a positive integer y satisfies xy0(modm), where x and m are both positive integers and 1xm. For example, f(12) = 2, as two pairs (6, 12) and (12, 12) meet the condition.

Define S(n)=m=1nf(m). You are given S(10) = 16 and S(1000) = 5764.

Find S(1014).
Thanks to baihacker for the idea.