We will prove that the required function f0 is g(n)=⌈log2∣n∣⌉+1.
(1) We prove that if g(n)=⌈log2∣n∣⌉+1 then g(n)∈F.
Consider numbers a,b∈Z∖{0} and a is not divisible by b. Assume that r′,s′ are integers such that a=br′+s′ with 0<s′<∣b∣.
If s′<2∣b∣ then we choose r=r′,s=s′.
If s′≥2∣b∣ then we choose r=r′±1,s=s′−∣b∣.
Therefore for all a,b we always have a=br+s with ∣s∣≤2∣b∣. In this case g(s)≤g(b)−1.
It means that we have a=br+s with g(b)>g(s), which satisfies the required condition.
(2) Let f0(n)=minf(n) for all n; We prove that f0∈F.
For all a,b there exists f such that f0(b)=f(b). We write a in the form a=br+s.
Since f(s)<f(b) we have f0(s)≤f(s)<f(b)=f0(b), therefore f0∈F.
(3) We will prove that f0(n)=g(n).
For n=±1, we have g(n)≥f0(n)≥1=g(1)⇒g(n)=f0(n).
Assume that there exists n for which f0(n)<g(n). We choose such n for which f0(n) is minimum and f0(n)<g(n). It is clear that n=±1.
Assume that r,s are integers such that f0(s)<f0(n) and a=br+s. Since f0(s)<f0(n) then f0(s)=g(s) for all s with ∣s∣>⌊2∣n∣⌋, g(s)≥g(n)−1, therefore g(n)>f0(n)>g(n)−1, which is absurd.
So, the required function f0 is f0(n)=⌈log2∣n∣⌉+1.