In a more simple way, what you wrote means

(i) the sum of the digits of a number is divisible by 3 if and only if the number is divisible by 3.

(ii) the sum of the digits of a number is divisible by 9 if and only if the number is divisible by 9.

(i) Let a number divisible by 3 be then

The number in front of the mod is the rest after dividing by the modulo number.

We can write any number as .

Remark that .

Therefore and .

It follows

And you have your answer that is

(ii) Since you can draw the same conclusions.