Proving that a number is divisible by 3 if and only if the sum of its digits is divisible by 3

I am currently taking a sets and numbers module at uni and wanted to get better at writing proofs. I would appreciate any feedback on how to improve my proof below.

For this proof we know that $9|(10^n-1)$ for all $n\in\mathbb{N}$

Suppose $f(n)$ is a number with $n$ digits $$f(n)=k_010^0+k_110^1+\cdots+k_{n-1}10^{n-1},\;\;\forall k\in\mathbb{N}$$Let $f^\prime(n)$ be the sum of $f(n)$'s digits $$f^\prime(n)=k_0+k_1+\dots+k_{n-1},\;\;\forall k\in\mathbb{N}$$We can see that $$f^\prime(n)=(k_010^0+k_110^1+\cdots+k_{n-1}10^{n-1})-(k_1(10^1-1)+k_1(10^2-1)+\cdots+k_{n-1}(10^{n-1}-1))$$We know that every term in $k_1(10^1-1)+k_1(10^2-1)+\cdots+k_{n-1}(10^{n-1}-1)$ is divisble by $9$ thus the entire sum is divisble by $9$. Let the sum be denoted by $v$. We can also see that $k_010^0+k_110^1+\cdots+k_{n-1}10^{n-1}$ is just $f(n)$. Therefore,$$f^\prime(n)=f(n)-v$$so$$f(n)-f^\prime(n)=v$$Now because v is divisible by $9$ we have that $f(n)-f^\prime(n)$ is also divisible by $9$ so $$\frac{f(n)-f^\prime(n)}{9}=q,\;\;\forall q\in\mathbb{N}$$which means that$$\frac{f(n)}{9}-\frac{f^\prime(n)}{9}=q$$Thus both $9|f(n)$ and $9|f^\prime(n)$. We have then proven that $f(n)$ is divisible $9$ iff $f^\prime(n)$ is divisible by $9$. By the transitivity of divisibility we then have that both $3|f(n)$ and $3|f^\prime(n)$. Therefore $f(n)$ is divisible by $3$ if and only if $f^\prime(n)$ is divisible by $3$. End of proof.


Looks mostly good to me. The core idea is excellent.

A couple of aesthetic concerns. For instance, you don't need any reference to $n$ in $f(n)$. It is enough to say

Let $f = k_0 + \cdots + k_{n-1}\cdot 10^{n-1}$ be an $n$-digit number, and $f' = k_0+\cdots + k_{n-1}$ be the sum of its digits.

Also, perhaps more importantly, I think you should stop once you reach $f'=f-v$. At that point, you know $v$ is divisible by $9$ (and therefore $3$), so it is almost an immediate consequence that $f$ is divisible by $9$ (or $3$) exactly when $f'$ is.


Suppose $f(n)$ is a number with n digits

I think it'd be better to specify what kind of number and not simply say digits but specify the precise mathematical thing you're using - so e.g. "Let $f(n) \in \Bbb N$ be a natural number with decimal expansion $f(n) = k_0 10^0 + k_1 10^1 + ... + k_n 10^n$. Furthermore I think your $f(n), f'(n)$ notation is extremely unfortunate since it clashes quite heavily with the common notation for functions and derivatives and there's no clear functional relationship here and it focuses the attention on the $n$ which isn't that important. So maybe make it $r \in \Bbb N$ and call the sum $\bar{r}, s, \sigma$ or something like that.

You should also pay attention to properly terminate your sentences with a full-stop, even if they end in symbols. It is also not very common to write something like "End of proof."; either omit this bit completely or include it into the flow of the text "By the transitivity of divisibility we then have that both $3|f(n)$ and $3|f′(n)$, which completes our proof that $f(n)$ is divisible by $3$ if and only if $f′(n)$ is divisible by $3$.".

As for the proof itself: if you're familiar with modular arithmetic you can try applying it to this theorem with great success - it'll trivialize the result.