← Complete problem index

PROJECT EULER · #0531

Chinese Leftovers

Statement only · SolvedOriginal problem ↗

Let g(a,n,b,m) be the smallest non-negative solution x to the system:
x=amodn
x=bmodm
if such a solution exists, otherwise 0.

E.g. g(2,4,4,6)=10, but g(3,4,4,6)=0.

Let ϕ(n) be Euler's totient function.

Let f(n,m)=g(ϕ(n),n,ϕ(m),m)

Find f(n,m) for 1000000n<m<1005000.

Write-up coming later

The complete problem is available here. An approach, code, and answer will be added later.