K
Khách

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.

10 tháng 11 2020

uses crt;

var a,d:array[1..100]of integer;

i,n,dem: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]>0 then

begin

inc(dem);

b[dem]:=a[i];

end;

writeln('So duong cuoi cung trong mang la: ',b[dem]);

readln;

end.

17 tháng 11 2019

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.

17 tháng 11 2019

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.

20 tháng 11 2019

1: VCT pascal kiểm tra số n có phải là số nguyên tố không

uses crt;

var n,i,kt:integer;

begin

clrscr;

repeat

write('nhap n='); readln(n);

if n<=1 then writeln('ban da nhap sai,yeu cau ban nhap lai');

until n>1;

kt:=0;

for i:=2 to n-1 do

if n mod i=0 then

begin

kt:=1;

break;

end;

if kt=0 then writeln(n,' la so nguyen to')

else writeln(n,' khong la so nguyen to');

readln;

end.

2:VCT pascal kiểm tra số n có phải là số hoàn hảo không

uses crt;
var n,i,t:integer;
begin
clrscr;
write('nhap n:'); readln(n);
t:=0;
for i:=1 to n-1 do
if n mod i=0 then begin
t:=t+i;
end;
if t=n then writeln(n,' la so hoan hao')
else write(n,' khong la so hoan hao');
readln;
end.

3:VCT pascal kiểm tra số n xuất ra màn hình các số nguyên tố từ 2 đến n

uses crt;
var n,i,kt,j:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if n<=2 then writeln('ban da nhap sai, yeu cau ban nhap lai');
until n>2;
writeln('day cac so nguyen to trong khoang tu 2 toi ',n,' la:');
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.

22 tháng 11 2019

bạn ơi bạn có thể giúp mình gộp 3 ý thành 1 bài ko

13 tháng 4 2023

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.

14 tháng 4 2023

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.

15 tháng 4 2023

Dùng app đúng không ạ.

16 tháng 4 2023

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.

 

15 tháng 4 2023

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.

22 tháng 5 2022

Tham Khảo :

uses crt;

var a,b,i:integer;

begin

clrscr;

write('Nhap a='); readln(a);

write('Nhap b='); readln(b);

if a<b then

begin

for i:=1 to a do

if (a mod i=0) and (b mod i=0) then write(i:4);

end

else begin

for i:=1 to b do

if (a mod i=0) and (b mod i=0) then write(i:4);

end;

readln;

end.

25 tháng 11 2019

1:

uses crt;
var n,t,i,j,kt:integer;
begin
clrscr;
write('nhap n='); readln(n);
if n>=2 then
begin
kt:=0;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then kt:=1;
if kt=0 then writeln(n,' la so nguyen to')
else writeln(n,' khong la so nguyen to');
end
else writeln(n,' khong la so nguyen to');
writeln('cac so nguyen to trong khoang tu 2 toi ',n,' la: ');
t:=0;
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
begin
write(i:4);
t:=t+i;
end;
end;
writeln;
writeln('tong cac so nguyen to trong khoang tu 2 toi ',n,' la: ',t);
readln;
end.

25 tháng 11 2019

số hoàn toàn là số như thế nào bạn?

29 tháng 4 2020

Program hotrotinhoc_hoc24;

var i,n: integer;

function nt(x: longint): boolean;

var j: longint;

begin

nt:=true;

if (x=2) or (x=3) then exit;

nt:=false;

if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;

j:=5;

while (j<=trunc(sqrt(x))) do

begin

if (x mod j=0) or (x mod (j+2)=0) then exit;

j:=j+6;

end;

nt:=true;

end;

begin

write('Nhap n='); readln(n);

if nt(n) then writeln(N ,'la so nguyen to') else writeln(N,' khong phai so nguyen to');

write('Cac so nguyen to tu 0 den ',n,' la :');

i:=0;

while i<=n do

begin

i=sqr(trunc(sqrt(i))) then write(i,' ');

i:=i+1;

end;

writeln;

write('Cac so nguyen to tu 2 den ',n,' la :');

i:=2;

while i<=n do

begin

if nt(i) then write(i,' ');

i:=i+1;

end;

readln

end.

Không dùng for do cô ơi