Ta có : \(S=3\left(1+11+111+...+11...1\right)\) (n chữ số 1)
\(=3\left(\frac{10-1}{9}+\frac{10^2-1}{9}+....\frac{10^n-1}{9}\right)=\frac{3}{9}\left(10+10^2+....+10^n-n\right)\)
\(=\frac{1}{3}\left(10.\frac{10^n-1}{10-1}-n\right)=\frac{1}{27}\left(10^{n+1}-10-9n\right)\)