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.
program TinhTongVaUocSo;
var
a, b, tong, i: integer;
laSoNguyenTo: boolean;
begin
write('Nhap a: ');
readln(a);
write('Nhap b: ');
readln(b);
tong := a + b;
writeln('Tong cua a va b la: ', tong);
writeln('Uoc so cua tong la:');
for i := 1 to tong do
begin
if tong mod i = 0 then
writeln(i);
end;
laSoNguyenTo := true;
if tong < 2 then
laSoNguyenTo := false
else
for i := 2 to trunc(sqrt(tong)) do
if tong mod i = 0 then
begin
laSoNguyenTo := false;
break;
end;
if laSoNguyenTo then
writeln('Tong a va b la so nguyen to')
else
writeln('Tong a va b khong phai la so nguyen to');
readln;
end.
program TinhTongVaUocCuaTong;
var a, b, tong, i: integer;
SoNguyenTo: boolean;
begin
writeln('Nhap vao hai so a va b (a > 0, b > 0): ');
write('a = ');
readln(a);
write('b = ');
readln(b);
tong := a + b;
writeln('Tong cua a + b = ', tong);
writeln('Uoc cua tong a + b: ');
for i := 1 to tong do
begin
if tong mod i = 0 then
writeln(i);
end;
SoNguyenTo := true;
if tong < 2 then
SoNguyenTo := false
else
for i := 2 to trunc(sqrt(tong)) do
begin
if tong mod i = 0 then
begin
SoNguyenTo := false;
break;
end;
end;
if SoNguyenTo then
writeln('Tong a + b la so nguyen to:')
else
writeln('Tong a + b khong phai la so nguyen to:');
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem,kt,j:integer;
begin
clrscr;
readln(n);
for i:=1 to n do write(i:4);
writeln;
for i:=2 to n do
begin
kt:=0;
for j:=2 to i-1 do
if i mod j=0 then kt:=1;
if kt=0 then write(i:4);
end;
readln;
end.
uses crt;
var a,b:array[1..100]of integer;
i,n,kt,dem,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to a[i]-1 do
if a[i] mod j=0 then kt:=1;
if kt=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
end;
if dem=0 then writeln('Khong co so nguyen to trong day')
else begin
writeln('Cac so nguyen to trong day la: ');
for i:=1 to dem do
write(b[i]:4);
end;
readln;
end.
program hoc24;
uses crt;
var a: array[1..100] of integer;
i,d,s: longint;
begin
clrscr;
for i:=1 to 6 do readln(a[i]);
s:=0;
for i:=1 to n do
if a[i]>0 then
begin
inc(d);
s:=s+a[i];
end;
writeln(d,s);
readln
end.
var tam,a,b,i:integer;
begin
write('a = ');readln(a);
write('b = ');readln(b);
if a < b then
begin
tam:=a;
a:=b;
b:=tam;
end;
for i:=a to b do
if sqrt(i) = trunc(sqrt(i)) then write(i:10);
readln;
End.
program TinhTongVaUoc;
var
a, b, sum, i: integer;
uoc: boolean;
begin
write('Nhap so a: ');
readln(a);
write('Nhap so b: ');
readln(b);
// Tinh tong a+b
sum := a + b;
writeln('Tong cua a va b la: ', sum);
// In ra cac uoc cua tong
write('Cac uoc cua tong a+b la: ');
for i := 1 to sum do
begin
if sum mod i = 0 then
write(i, ' ');
end;
writeln;
// Kiem tra xem tong a+b co phai la so hoan hao hay khong
uoc := false;
for i := 1 to sum - 1 do
begin
if sum mod i = 0 then
uoc := true;
end;
if uoc and (sum = 2 * sum div 2) then
writeln('Tong a+b la so hoan hao')
else
writeln('Tong a+b khong phai la so hoan hao');
end.
uses crt;
var a,b,c:array[1..100]of integer;
i,n,dem,dem1,kt,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if sqrt(a[i])=trunc(sqrt(a[i])) then
begin
inc(dem);
b[dem]:=a[i];
end;
dem1:=0;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to trunc(sqrt(a[i])) do
if a[i] mod j=0 then kt:=1;
if kt=0 then
begin
inc(dem1);
c[dem1]:=a[i];
end;
end;
if dem=0 then writeln('Trong day khong co so chinh phuong')
else begin
writeln('Cac so chinh phuong trong day la: ');
for i:=1 to dem do
write(b[i]:4);
end;
if dem1=0 then writeln('Trong day khong co so nguyen to')
else begin
writeln('Cac so nguyen to trong day la: ');
for i:=1 to dem1 do
write(c[i]:4);
end;
readln;
end.