Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

Đề sai đúng không, bạn kiểm tra lại đề nhé, mình không thấy quy luật gì trong dãy tổng của S cả
Viết chương trình pascal for to do để tính tổng S=2+4+6+...+n. N là số nguyên nhập từ bàn phím

var n, s, i: integer;
begin
write('Nhap n = ');
readln(n);
s := 0;
i := 3;
while i <= n do
begin
s := s + i;
i := i + 3;
end;
writeln('Tong la ', s);
readln;
end.
program tinh_tong_S;
var
n, i, S: integer;
begin
write('Nhap n: ');
readln(n);
S := 0;
for i := 3 to n step 1 do
begin
if i mod 2 = 0 then
S := S + i;
end;
writeln('Tong S la: ', S);
readln;
end.

Em tham khảo nhé.
Đây là chương trình tìm tổng A:
```
var n, A: real;
write('Nhap vao so n: ');
readln(n);
A := 0;
for var i := 1 to Round(n) do
begin
A := A + 1/i;
end;
writeln('Tong A la: ', A:0:2);
```
Giải thích chương trình:
1. Sử dụng lệnh `readln` để nhập giá trị `n` từ bàn phím.
2. Khởi tạo biến `A` là 0.
3. Sử dụng vòng lặp `for` để tính tổng từ 1 đến `n`.
4. Cộng giá trị của 1/i vào biến `A`.
5. In ra giá trị của `A` với độ chính xác 2 chữ số thập phân bằng lệnh `writeln`.

uses crt;
var s,p,i,n:integer;
begin
clrscr;
readln(n);
s:=0;
p:=1;
for i:=1 to n do
begin
s:=s+i;
p:=p*i;
end;
writeln(s);
writeln(p);
readln;
end.

var i,n,s:longint;
begin
read(n); if n<2 then break;
for i:=3 to n do s:=s+i;
write(s);
end.
Var i,n:integer;
t:longint;
Begin
Write('n = ');readln(n);
i:=2;
While i<=n do
Begin
t:=t+i;
i:=i+1;
End;
Write('Tong la ',t);
Readln
End.

#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,t=0;
cin>>n;
for (int i=1; i<=n; i++)
if (i%6==0) t+=i;
cout<<t;
return 0;
}

var i,n,s:integer;
begin
write('nhap n = ');readln(n);
i:=1;
while i<=n do
begin
s:=s+i;
i:=i+1;
end;
write('Tong la ',s);
readln;
end.

uses crt;
var i,n,s:integer;
begin
clrscr;
readln(n);
s:=0;
i:=0;
while i<=n do
begin
i:=i+1;
s:=s+i*i;
end;
writeln(s);
readln;
end.
Var i,n:integer;
s:longint;
Begin
Write('n = ');readln(n);
For i:=1 to n do
s:=s + 2*i;
Write('Tong la ',s);
Readln;
End.