Những câu hỏi liên quan
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.

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;
}

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...  

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.

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.

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;

}

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;

}

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.

Quỳnh Trâm Nguyễnn
Xem chi tiết
Kiều Vũ Linh
7 tháng 5 2022 lúc 13:31

Var n,i,souoc:integer;

Begin

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

souoc:=0;

For i:=1 to n do

If n mod i = 0 then souoc:=souoc+1;

If souoc=2 then write(n,' la so nguyen to')

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

Readln;

End.

Nguyễn Hoàng Duy
20 tháng 3 2023 lúc 23:26

program KiemTraSoNguyenTo;
var
  N, i: integer;
  IsPrime: boolean;
begin
  write('Nhap N: ');
  readln(N);

  IsPrime := true;
  if (N < 2) then
    IsPrime := false
  else
    for i := 2 to trunc(sqrt(N)) do
      if (N mod i = 0) then
      begin
        IsPrime := false;
        break;
      end;

  if IsPrime then
    writeln(N, ' la so nguyen to')
  else
    writeln(N, ' khong la so nguyen to');

  readln;
end.

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";

}

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;
}

Minh Ngọc
Xem chi tiết
lê thị bích ngọc
7 tháng 12 2021 lúc 19:37

mình chưa hiểu rõ đề lắm nên mình sẽ làm tạm như thế này còn nếu bạn muốn kiểu khác thì cứ bình luận để mình làm lại.

câu 1 :

#include<iostream>

using namespace std;

int main() {

long long a;

cout << "giá trị của a: "; cin >> a;

if (a % 2 != 0 && a % 5 == 0) {

cout << "a là một số lẻ chia hết cho 5"

} else {

cout << "a không phải là một số lẻ chia hết cho 5";

}

return 0;

}

câu 2 :

#include<iostream>

using namespace std;

int main() {
int a;

cout << "giá trị của a là: "; cin >> a;

if (a % 2 == 0 && a % 5 == 0) {

cout << "a là một số chẵn chia hết cho 5";

} else {
cout << "a không phải là một số chẵn chia hết cho 5";

}

return 0;

}

(Mình viết ở ngôn ngữ C++)