Let $f: \mathbb{N} \rightarrow \mathbb{R}$ be a function and $a \in \mathbb{R}$ such that $$f(m+n) = f(m) + f(n) + a$$ $$f(2) = 10, f(20) = 118$$ Find $a$ and $f$.
I found this exercise at the beginning of a Real Analysis textbook. I've never solved a functional equation before, but here's my solution (attempt):
i) Using induction it's easy to verify that for $m, n \in \mathbb{N}$ we have $f(m \cdot n) = m (f(n) + a)$, since $$f((m+1)n) = f(mn + n) = f(mn) + f(n) + a$$
ii) Then $118 = f(20) = f(10 \cdot 2) = 10 (f(2) + a) = 10 (10 + a) \Rightarrow a = \frac{9}{5}$
iii) Then $f(0) = f(0 + 0) = f(0) + f(0) + a \Rightarrow f(0) = -a = -\frac{9}{5}$.
We also get $10 = f(2) = f(1+1) = f(1) + f(1) + \frac{9}{5} = 2 f(1) + \frac{9}{5} \Rightarrow f(1) = \frac{41}{10}$
iv) Then finally we can define $f$ recursively by $f(0) = -\frac{9}{5}$ and $$f(n+1) = f(n) + f(1) + \frac{9}{5} = f(n) + \frac{41}{10} + \frac{9}{5} = f(n) + \frac{59}{10}$$
EDIT
Then thanks to the user lulu, the real pattern should be $f(m \cdot n) = m f(n) + (m-1) a$ instead. Using this in ii) then gives $a = 2$. Then we get in iii) that $f(0) = -2$ and $f(1) = 4$, so $f$ is defined by $f(n+1) = f(n) + 6$. And now it's pretty obivous that $f(n) = 6n - 2$ solves the equation.
HINT:
We have $$f(20)=2f(10)+a=10f(2)+9a\implies a=2$$
Now consider $$f(m-n)=f(m)+f(-n)+2\\f(m+n)=f(m)+f(n)+2$$ and adding gives $$f(m-n)+f(m+n)=2f(m)+f(-n)+f(n)+4$$ or $$f(2m)-2=2f(m)+f(0)-2+4$$ Now what do we know about $f(0)$?