Prove by mathematical induction that $(3n+1)7^n -1$ is divisible by $9$ for integral $n>0$

You're almost finished.

You assume that $S_k = 7^k(3k+1)-1$ is divisible by 9, and therefore divisible by 3.

$S_k = 7^k(3k)+ 7^k-1$ is divisible by 3.

Therefore $7^k-1$ is divisible by 3.

let $3x = 7^k-1$.

$7^k=3x+1$

Then in your final steps:

$=63P+6+21\cdot7^k$

$=63P+6+21(3x+1)$

$=63P+63x+27$

$=9(7P+7x+3)$


Another, less elegant way of proving it is using modular arithmetic. In essence, we show that if $$7^n(3n+1)-1\equiv0 \mod9$$ And, for the inductive step, $$7^{n+1}(3(n+1)+1)-1=7^{n+1}(3n+4)-1=7(7^n(3n+1)-1+1+3\cdot7^n)-1$$ Using congruence mod $9$: $$6+3\cdot7^n\equiv0\mod9$$ For all $n\in\mathbb{Z}_9$, which implies what we wanted to show.