TITLE: Does $f'(x)\in \mathbb Z$ a.e. implies that $f$ is an affine function?
QUESTION [18 upvotes]: Conjecture: Let $f: \mathbb R \to \mathbb R$ be an everywhere differentiable function and  assume that $f'(x) \in \mathbb Z$ almost everywhere. Then is $f$ necessarily an affine function?
Can you give me a proof or a counter-example ? I thought of the devil's staircase, but this is not differentiable everywhere.

REPLY [2 votes]: Yes, $f'$ must be constant. This has been answered in the comments; the result in https://mathoverflow.net/questions/266377/how-quickly-can-the-derivative-of-an-everywhere-differentiable-function-change-s gives a kind of positive measure Darboux theorem. This is a special case of How irregular can $f'$ be beyond Darboux's Theorem?