Những câu hỏi liên quan
MinhThu
Xem chi tiết
Kiều Vũ Linh
13 tháng 4 2023 lúc 13:59

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.

Bình luận (0)
HT.Phong (9A5)
13 tháng 4 2023 lúc 12:56

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.

Bình luận (0)
Kỳ AnH
Xem chi tiết
Phan Vũ Nhật Huy
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 11 2019 lúc 21:36

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.

Bình luận (0)
 Khách vãng lai đã xóa
Nguyễn Lê Phước Thịnh
25 tháng 11 2019 lúc 21:37

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

Bình luận (0)
 Khách vãng lai đã xóa
Nguyễn Chơn Nhân
26 tháng 11 2019 lúc 10:11

1:

var
n:int64;
function snt2(n:int64):boolean;
var
k:longint;
begin
if n<=1 then exit (false);
if (n=3) or (n=2) then exit (true);
if (n mod 2=0) or (n mod 3=0) then exit (false);
for k:=1 to (trunc(sqrt(n))+1)div 6 do
if (n mod (6*k-1)=0) or (n mod (6*k+1)=0) then exit (false);
exit(true);
end;

begin
readln (n);
if snt2(n)=true then writeln (n,'la so nguyen to')
else writeln (n,'khong la so nguyen to');
readln;
end.

Bình luận (0)
 Khách vãng lai đã xóa
Linh Nga Nguyễn
Xem chi tiết
Sơn Mai Thanh Hoàng
15 tháng 3 2022 lúc 15:05

1 không

2 

 Program UCLN;

uses crt;

var a,b : integer;

begin

write ('nhap so a la ');readln (a);

write ('nhap so b la ');readln (b);

while a < > b do

if a >b then a := a - b else b := b - a ;

write ( ' UCLN la :' , a );

readln

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
15 tháng 3 2022 lúc 20:33

1: 

#include <bits/stdc++.h>

using namespace std;

int n,i;

bool kt;

int main()

{

cin>>n;

kt=true;

for (i=2; i*i<=n; i++)

if (n%i==0) kt=false;

if (kt==true && n>1) cout<<"La so nguyen to";

else cout<<"Khong la so nguyen to";

return 0;

}

Bình luận (0)
MinhThu
Xem chi tiết
Ngô Bá Hùng
16 tháng 4 2023 lúc 8:09

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.

 

Bình luận (0)
MinhThu
Xem chi tiết
Nguyễn Hoàng Duy
15 tháng 4 2023 lúc 21:05

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.

Bình luận (0)
MinhThu
Xem chi tiết
Ngô Bá Hùng
14 tháng 4 2023 lúc 21:49

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.

Bình luận (4)
Lê Huỳnh Nhân
Xem chi tiết
Nguyễn Lê Phước Thịnh
28 tháng 2 2023 lúc 22:56

2:

#include <bits/stdc++.h>

using namespace std;

int main()

{

int n,i,kt=0;

cin>>n;

for (int i=2; i*i<=n; i++)

if (n%i==0) kt=1;

if (kt==0) cout<<"YES";

else cout<<"NO";

}

Bình luận (0)
Le thi huong
Xem chi tiết
Kiều Vũ Linh
10 tháng 5 2023 lúc 19:13

Câu 58:

Var n:integer;

Begin

Write('n = ');readln(n);

If n mod 2 <> 0 then write(n,' la so le')

Else write(n,' khong la so le');

Readln

End.

Bình luận (0)
Kiều Vũ Linh
10 tháng 5 2023 lúc 19:14

Câu 61:

Var n:integer;

Begin

Write('n = ');readln(n);

If n mod 2 = 0 then write(n,' la so chan')

Else write(n,' khong la so chan');

Readln

End.

Bình luận (0)