Những câu hỏi liên quan
Minh Ngọc
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 12 2021 lúc 23:53

 

 

#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)
Bảo Châu Lê
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 12 2022 lúc 13:52

Câu 2:

#include <bits/stdc++.h>

using namespace std;

long long n;

int main()

{

cin>>n;

if (n>0 && n%5==0) cout<<"Phai";

else cout<<"Khong phai";

}

Bình luận (0)
Lucky Kate
Xem chi tiết
Bao112233
17 tháng 12 2022 lúc 21:22

b) 

#include <iostream>
using namespace std;
int a;
int main(){
    cin>>a;
    if (a%2==0) cout<<a<<" la so chan";
    else cout<<a<< "la so le";
    return 0;
}

Bình luận (0)
misha
Xem chi tiết
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)
T Đạt
Xem chi tiết
Thanh Phong (9A5)
29 tháng 3 2023 lúc 16:00

Uses crt;

var n,i,z: integer;

begin clrscr;

readln(n);

for i:=1 to n do if(n mod i=0) then z:=z+1;

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

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

readln;

end.

Bình luận (0)
Nguyễn Hoàng Duy
29 tháng 3 2023 lúc 23:45

program PrimeNumber;

uses crt;

var
  N, i: integer;
  isPrime: boolean;

begin
  clrscr;
  write('Enter N: ');
  readln(N);

  if N <= 1 then
  begin
    writeln('N is not a prime number');
  end
  else
  begin
    isPrime := true;
    for i := 2 to trunc(sqrt(N)) do
    begin
      if N mod i = 0 then
      begin
        isPrime := false;
        break;
      end;
    end;

    if isPrime then
    begin
      writeln('N is a prime number');
    end
    else
    begin
      writeln('N is not a prime number');
    end;
  end;

  readln;
end.

Bình luận (0)
Hân Chướng
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 12 2021 lúc 8:43

#include <bits/stdc++.h>

using namespace std;

long long n;

int main()

{

cin>>n;

if (n%2==0) cout<<"YES";

else cout<<"NO";

return 0;

}

Bình luận (0)
Veres Pro
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 5 2022 lúc 13:10

#include <bits/stdc++.h>

using namespace std;

long long n;

int main()

{

cin>>n;

bool kt=true;

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

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

if (kt==true && n>=2) cout<<"YES";

else cout<<"NO";

return 0;

}

Bình luận (0)
Quỳnh Trâm Nguyễnn
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 5 2022 lúc 23:57

uses crt;

var n,i,kt:integer;

begin

clrscr;

readln(n);

kt:=0;

for i:=2 to trunc(sqrt(n)) do 

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

if (kt=0) and (n>1) then write('phai')

else write('Khong phai');

readln;

end.

Bình luận (0)