Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
//Write a program in Pascal to find the sum of the series 1 +11 + 111 + 1111 + .. n terms.
Program sum_series;
var t, n, i, total, sum :integer;
begin
t:= 1;
writeln('Input the number of terms: ');
readln(n);
for i:= 1 to n do
begin
write(t);
if (i < n) then
write(' + ');
sum := sum + t;
t := (t *10) + 1;
end;
writeln;
writeln('The sum is : ', sum);
end.
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more