![](https://rs.olm.vn/images/avt/0.png?1311)
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.
![](https://rs.olm.vn/images/avt/0.png?1311)
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var i,n,d:longint;
begin
d:=0;
writeln('nhapn=');read(n);
for i:=1 to n do
begin
if i mod 3=0 then write(i,' ');
if i mod 3=0 then d:=d+i;
end;
writeln('tong=',d);
readln;
end;
![](https://rs.olm.vn/images/avt/0.png?1311)
1:
#include <bits/stdc++.h>
using namespace std;
long long dem,i,n,x;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0) dem++;
}
cout<<dem;
return 0;
}
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%3==0) t+=x;
}
cout<<t;
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
Bài 1:
uses crt;
var n,i,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
for i:=1 to n do
if i mod 6=0 then s:=s+i;
writeln(s);
readln;
end.
Bài 2:
uses crt;
var a,b,c,ucln,i:integer;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
write('c='); readln(c);
while a<>b do
begin
if a>b then a:=a-b
else b:=b-a;
end;
ucln:=a;
while ucln<>c do
begin
if ucln>c then ucln:=ucln-c
else c:=c-ucln;
end;
writeln(ucln);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var n,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 3=0 then
begin
write(i:4);
t:=t+i;
end;
writeln;
writeln('Tong cac so chia het cho 3 la: ',t);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Var s,n,i,so:integer;
Begin
Write('Nhap so luong so n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i)readln(so);
If so mod 2 = 0 then s:=s+so;
End;
Write('Tong cac so chan la ',s);
Readln;
End.
![](https://rs.olm.vn/images/avt/0.png?1311)
program TinhTong;
uses crt;
var
n, i, tong: integer;
begin
clrscr;
write('Nhap vao so nguyen duong n: ');
readln(n);
tong := 0;
for i := 1 to n-1 do begin
if i mod 2 <> 0 then
tong := tong + i;
end;
writeln('Tong cac so khong chia het cho 2 la: ', tong);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
program tinhTong;
var
n,i,s: integer;
a: array[1..100] of integer;
begin
write('Nhap so luong phan tu: ');
readln(n);
for i := 1 to n do
begin
write('a[',i,'] = ');
readln(a[i]);
end;
s := 0;
for i := 1 to n do
begin
if (a[i] mod 5 <> 0) then
s := s + a[i];
end;
writeln('Tong cac so khong chia het cho 5: ', s);
readln;
end.
program TinhTong;
var
n, i, s, x: integer;
begin
write('Nhap so luong phan tu cua day: ');
readln(n);
s := 0;
for i := 1 to n do
begin
write('Nhap phan tu thu ', i, ': ');
readln(x);
if (x mod 5 <> 0) then
s := s + x;
end;
writeln('Tong cac so khong chia het cho 5 la: ', s);
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
1:
uses crt;
var i,j,t,kt:integer;
begin
clrscr;
t:=0;
for i:=1 to 100 do
if i>1 then
begin
kt:=0;
for j:=2 to i-1 do
if i mod j=0 then kt:=1;
if kt=0 then t:=t+i;
end;
writeln(t);
readln;
end.
Câu 2:
*Viết chương trình:
uses crt;
var n,p,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for p:=2 to n-1 do
if n mod p=0 then t:=t+p;
writeln('Tong cac uoc that su cua ',n,' la: ',t);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Viết chương trình nhập vào số nguyên n và tính tổng các số lẻ (các số lẻ là số không chia hết cho 2) trong khoảng từ 1 đến n ( ví dụ nhập = 10, ta sẽ có tổng sau s=1+3+5+7+9=25)
uses crt;
var i,n,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
for i:=1 to n do
if i mod 2=1 then s:=s+i;
writeln(s);
readln;
end.
program tinh_tong_chia_het_cho_6;
uses crt;
var
n, i, tong: integer;
begin
write('Nhap so N: ');
readln(n);
tong := 0;
for i := 1 to n do
begin
if i mod 6 = 0 then
begin
tong := tong + i;
end;
end;
writeln('Tong cac so chia het cho 6 la: ', tong);
readln;
end.