Những câu hỏi liên quan
Trần Long
Xem chi tiết
Trần Long
Xem chi tiết
Nhi Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
11 tháng 3 2022 lúc 15:49

#include <bits/stdc++.h>

using namespace std;

bool kt;

int n,i;

int main()

{

cin>>n;

kt=true;

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

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

if ((kt==true) and (n>1)) cout<<"YES";

else cout<<"NO";

return 0;

}

 

Bình luận (0)
nguyễn thị như ý
Xem chi tiết
nguyễn an phát
17 tháng 4 2021 lúc 20:14

program tim_uoc;

uses crt;

var n,i,j:longint;

begin

clrscr;

write('nhap so n:');readln(n);

write('cac uoc cua n la:');

for i:=1 to n do

if n mod i=0 then write(i:3);

writeln;

j:=0;

for i:=1 to n do

if n mod i=0 then j:=j+1;

if j=2 then writeln(n,' la so nguyen to')

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

readln;

end.

Bình luận (0)
Minh Ngọc
Xem chi tiết
Nguyễn Anh Dũng
9 tháng 12 2021 lúc 20:50

var x, i : integer;

begin

     writeln('nhap so nguyen x : ')

     read(x);

     if ( x < 2) then writeln(' x khong phai so nguyen to');

     else if ( x > 2) then

        begin

              for i := 2 to ( x - 1) do

                  begin

                     if ( x mod i = 0) then writeln(' x khong la so nguyen to');

                  end;

        end;

    else

        writeln(' x la so nguyen to');

    readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
9 tháng 12 2021 lúc 23:11

#include <bits/stdc++.h>
using namespace std;
long long n;
//chuongtrinhcon
bool ktnt(long long n)
{
    if (n<2) return(false);
    else
    for (int i=2; i*i<=n;i++)
        if (n%i==0) return (false);
    return(true);

}
//chuongtrinhchinh
int main()
{
    //freopen("KTSNT.INP","r",stdin);
    //freopen("KTSNT.OUT","w",stdout);
    cin>>n;
    if (ktnt(n)==true) cout<<"1";
    else cout<<"0";
    return 0;
}

Bình luận (0)
Nguyễn Văn Hồng
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 3 2023 lúc 20:05

loading...  

Bình luận (2)
Nguyễn Hoàng Duy
26 tháng 3 2023 lúc 21:02

program kiem_tra_so_nguyen_to;

var
  N, i: Integer;
  laSoNguyenTo: Boolean;

begin
  Write('Nhap vao mot so nguyen duong N: ');
  Readln(N);

  laSoNguyenTo := True;
  
  if (N < 2) then
    laSoNguyenTo := False
  else
  begin
    for i := 2 to N - 1 do
    begin
      if (N mod i = 0) then
      begin
        laSoNguyenTo := False;
        Break;
      end;
    end;
  end;

  if (laSoNguyenTo) then
    Writeln(N, ' la so nguyen to')
  else
    Writeln(N, ' khong la so nguyen to');
    
  Readln;
end.

Bình luận (0)
Vu Hoang Anh
Xem chi tiết

#include <bits/stdc++.h>
using namespace std;
bool ktsnt(long long n)
{
    long long i;
if(n<2) return false;
    else
    {
        for(i=2;i<=sqrt(n);i++)
            if(n%i==0)
            return false;
        return true;
    }
}
long long cnt;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>cnt;
if(ktsnt(cnt)==true)
    cout<<"YES";
else
    cout<<"NO";
return 0;
}

 

Bình luận (0)
Kiều Vũ Linh
10 tháng 2 2022 lúc 16:23

var i,n,dem:integer;

begin

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

for i:=1 to n do

begin

if n mod i = 0 then dem:=dem+1;

end;

if dem = 2 then write(n,' la so nguyen to')

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

readln;

end.

 

Bình luận (0)
8/1 Ngọc Hân
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 4 2022 lúc 22:26

c: 

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++)

if (a[i]%2==0) cout<<a[i]<<" ";

return 0;

}

d: 

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,nn;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

nn=a[1];

for (i=1; i<=n; i++) nn=min(nn,a[i]);

cout<<nn;

return 0;

}

Bình luận (0)
Dân Phạm Văn
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 21:20

Bài 1: 

uses crt;

var n,i,kt:integer;

begin

clrscr;

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

kt:=0;

for i:=2 to n-1 do 

 if n mod i=0 then kt:=1;

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

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

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 21:21

Bài 2: 

uses crt;

var n,i:integer;

begin

clrscr;

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

for i:=1 to n do 

 if n mod i=0 then write(i:4);

readln;

end.

Bình luận (0)