This is the same as 7(1+11+111+...). Note that the individual terms in parentheses are each a geometric progression (GP) with first term 1 and common ratio 10, i.e., 1+10+102+103+... so the sum in parentheses is the sum of a sequence of GPs.
For n≥0 the nth term is 7(10n+1-1)/(10-1)=(7/9)(10n+1-1).
For example, when n=0, the term is (7/9)(10-1)=7;
when n=3, the term is (7/9)(104-1)=(7/9)(9999)=7777.
The sum of the GP terms is Sn:
Sn=(7/9)(101-1+102-1+103-1+...+10n+1-1)=
(7/9)(101+102+103+...+10n+1-(n+1))=
(70/9)(1+10+102+...+10n-(n+1)/10)=
(70/9)[(10n+1-1)/9-(n+1)/10)]=
(70/9)[10(10n+1-1)-9(n+1)]/90=
(7/81)(10n+2-9n-19).
When n=0, S0=(7/81)(100-19)=7;
when n=3, S3=(7/81)(100000-27-19)=(7/81)(99954)=8638.
7+77+777+7777=8638. Note that S3 is the sum of the first 4 terms because n starts at zero.
So the formula is correct: Sn=(7/81)(10n+2-9n-19) for integer n≥0. Under this formula, Sn means the sum of the first n+1 terms.
Note that the sum of the first 9 terms is S8=7×123,456,789=864,197,523; S7=7×12,345,678=86,419,746, etc.
However, S9=7×1,234,567,900=8,641,975,300;
S10=7×12,345,679,011=86,419,753,077.
The formula can be written Sn=(7/81)(10n+1-9n-10) so S1=(7/81)(81)=7 for integer n≥1. Under this formula Sn means the sum of the first n terms. S1 is just the first term in this case.