Let P be the set of primes not exceeding 10100. For each p∈P, let ep=maxxνp(f(x)) and let cp=xargmaxνp(f(x)).
We show that this is good enough to compute all values of x, by looking at the exponent at each individual prime.
Claim — For any p∈P, we have
νp(f(x))=min(νp(x−cp),ep).
Proof. Note that for any x, we have
gcd(f(cp),f(x))=gcd(f(cp),x−cp).
We then take νp of both sides and recall νp(f(x))≤νp(f(cp))=ep; this implies the result. □
This essentially determines f, and so now we just follow through. Choose n and m such that
n=p∈P∏pepm≡−cp(modpep)∀p∈P
the latter being possible by Chinese remainder theorem. Then, from the claim we have
f(x)=p∈P∏pνp(f(x))=p∤n∏pmin(νp(x−cp),ep)=p∣n∏pmin(νp(x+m),νp(n))=gcd(x+m,n)
for every x∈Z, as desired.