All functions of the form f(x)=cx with c∈R are solutions; they are the only ones. More generally let b>a>0, and let the open interval Δ=(a,b) contain an integer (in our case a=106−10−6, b=106+10−6). Consider any function f:N→R such that f(x+y)=f(x)+f(y) holds whenever yx∈Δ. We prove that f(n)=cn for all n∈N with a real constant c.
To begin with let us show that f(n+1)−f(n)=f(n)−f(n−1) for all sufficiently large n. The reason is that for each sufficiently large n∈N there is a z∈N such that
f(n+1)−f(n)=f(z+1)−f(z)=f(n)−f(n−1).
To ensure the first equality it is enough to take a z so that n+1z∈Δ and nz+1∈Δ. Then by hypothesis f(x+y)=f(x)+f(y) will hold with x=z, y=n+1 and also with x=z+1, y=n. Hence f(z)+f(n+1)=f(n+z+1)=f(z+1)+f(n), as desired. Likewise the second equality will hold provided that nz∈Δ and n−1z+1∈Δ. Since n+1z<nz<nz+1<n−1z+1, it suffices to find an integer z so that a<n+1z and n−1z+1<b, i.e. a(n+1)<z<b(n−1)−1. Such an integer does exist for n large enough. Indeed b(n−1)−1 and a(n+1) differ by (b−a)n−(a+b+1) which is greater than 1 for n>b−aa+b+2.
In summary there exists a k∈N such that f(n+1)−f(n) has the same value for all n≥k. Then by standard induction
(∗)f(n)=(n−k)[f(k+1)−f(k)]+f(k)for all n≥k.
There are x,y∈N such that x,y≥k and yx∈Δ. For instance choose a rational sr∈Δ (r,s∈N) and set x=rk,y=sk. Take one such pair x,y and compute f(x),f(y),f(x+y) by the formula (∗); this can be done because x,y,x+y≥k. Replace the obtained values in f(x+y)=f(x)+f(y), which holds because yx∈Δ. Simplification leads to kf(k+1)=(k+1)f(k). Hence kf(k)=k+1f(k+1)=c∈R; equivalently f(k)=ck and f(k+1)=c(k+1). Then (∗) takes the form f(n)=cn for all n≥k. It remains to show that f(n)=cn for all n∈N.
Only finitely many n∈N may possibly disobey f(n)=cn. Suppose that such values exist, and let q be the greatest one of them. Choose an integer w∈Δ and set x=wq,y=q. Then x/w∈Δ, hence f((w+1)q)=f(wq)+f(q). If w>1 then (w+1)q>wq>q, so by the choice of q we have f((w+1)q)=c(w+1)q, f(wq)=cwq. However then f(q)=c(w+1)q−cwq=cq, contrary to the assumption that q violates f(n)=cn. And if w=1 then (w+1)q=2q>q, so f(2q)=2cq. On the other hand f((w+1)q)=f(wq)+f(q) takes the form f(2q)=2f(q) which leads to the impossible f(q)=cq again. This completes the proof.
*Remark.* The main assumption is f(x+y)=f(x)+f(y) whenever yx∈Δ, where Δ is an arbitrary open interval with positive endpoints. It ensures f(n)=cn for all sufficiently large values of n. However the additional assumption that Δ contains an integer is essential to infer that f(n)=cn for all n∈N. Consider for instance the function f:N→R defined by f(n)=n for n≥5 and f(n)=2010 for n∈{1,2,3,4} (in fact f(1),f(2),f(3),f(4) can be arbitrary). The interval Δ=(3/2,5/3) does not contain fractions with denominators 1,2,3,4. So yx∈Δ implies x≥y≥5; the equation f(x+y)=f(x)+f(y) is satisfied for such values. Thus f is a function that satisfies the main assumption and f(n)=n for n≥5 but not for all n.