VCT pascal nhập hai số a;b (a>0 ; b>0) Xuất ra màn hình các số chính phương từ a-b giúp mình với ạ😭mình đang cần gấp!!!
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.
uses crt;
var n,i,dem,dem1:integer;
begin
clrscr;
write('nhap n='); readln(n);
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if i mod 2=0 then inc(dem);
if i mod 2=1 then inc(dem1);
end;
writeln('so luong so chan trong day so tu 1 toi ',n,' la: ',dem);
writeln('so luong so le trong day so tu 1 toi ',n,' la: ',dem1);
readln;
end.
var n,i:longint;
begin
readln(n);
if n mod 2=0 then write('chan: ',n div 2,' le: ',n div 2) else
write('chan: ',n div 2,' le: ',n div 2+1) ;
end.
var i,n:integer;
begin
write('n = ');readln(n);
i:=2;
while n mod i <> 0 do i:=i+1;
if i = n then write(n,' la so nguyen to')
else write(n,' khong la so nguyen to');
readln
end.
Uses crt;
var i,n,p: integer;
begin clrscr;
readln(n);
for i:=1 to n do if(n mod i=0) then p:=p+1;
if(p=2) then writeln(n,' la so nguyen to')
else writeln(n,' khong phai la so nguyen to');
readln;
end.
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.
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 i,n,z: longint;
begin clrscr;
readln(n);
z:=1;
while(i<n) do begin
i:=i+1;
z:=z*i;
end;
writeln(z);
readln;
end.
program TinhGiaiThua;
var n, giaiThua: integer;
begin
writeln('Nhap vao gia tri cua n (>0): ');
readln(n);
if n <= 0 then
begin
writeln('Gia tri cua n phai lon hon 0.');
exit;
end;
giaiThua := 1;
while n > 0 do
begin
giaiThua := giaiThua * n;
n := n - 1;
end;
writeln('Giai thua cua n la: ', giaiThua);
readln;
end.
uses crt;
var b:array[1..5]of integer;
i,n,dem,k,tam,j:integer;
kt:boolean;
begin
clrscr;
n:=5;
for i:=1 to n do readln(b[i]);
for i:=1 to n do write(b[i]:4);
writeln;
dem:=0;
for i:=1 to n do if b[i] mod 2=0 then dem:=dem+1;
writeln('So luong so chan la: ',dem);
readln(k);
kt:=false;
for i:=1 to n do
if b[i]=k then
begin
write(i:4);
kt:=true;
end;
if (kt==false) then writeln('Khong co k trong day')
else writeln;
for i:=1 to n-1 do
for j:=i+1 to n do
if b[i]>b[j] then
begin
tam:=b[i];
b[i]:=b[j];
b[j]:=tam;
end;
for i:=1 to n do write(b[i]:4);
readln;
end.
uses crt;
var i,n,dem:integer;
begin
clrscr;
readln(n);
dem:=0;
i:=1;
while i<=n do
begin
if trunc(sqrt(i))=sqrt(i) then begin inc(dem); write(i:4);
end;
i:=i+1;
end;
writeln;
writeln(dem);
readln;
end.
uses crt;
var a,b,c,ucln,bcnn,i,min:longint;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
min:=a;
if min>b then min:=b;
if min>c then min:=c;
ucln:=1;
for i:=1 to min do
if (a mod i=0) and (b mod i=0) and (c mod i=0) then
begin
if ucln<i then ucln:=i;
end;
bcnn:=a*b*c;
for i:=a*b*c downto 1 do
if (i mod a=0) and (i mod b=0) and (i mod c=0) then
begin
if bcnn>i then bcnn:=i;
end;
writeln('Uoc chung lon nhat: ',ucln);
writeln('Boi chung nho nhat: ',bcnn);
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.