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

Bình luận (0)
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ì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)
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)
Huy Nguyễn
Xem chi tiết
Nguyễn Hoàng Duy
20 tháng 3 2023 lúc 23:18

program BangCuuChuong;
var
  N, i, j: integer;
  IsEven: boolean;
  IsPrime: boolean;
begin
  write('Nhap N (0 < N < 10): ');
  readln(N);

  // Kiểm tra N có phải số chẵn hay lẻ
  IsEven := (N mod 2 = 0);
  if IsEven then
    writeln(N, ' la so chan')
  else
    writeln(N, ' la so le');

  // Kiểm tra N có phải số nguyên tố hay không
  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');

  // In ra bảng cửu chương N
  writeln('Bang cuu chuong ', N, ':');
  for i := 1 to 10 do
  begin
    j := i * N;
    writeln(N, ' x ', i, ' = ', j);
  end;

  readln;
end.

Mấy cái phần mình gạch // là giải thích phần code đó làm gì nha.

Bình luận (0)
Minh Lệ
20 tháng 3 2023 lúc 22:05

Program HOC24;

var i,n,d: byte;

begin

write('Nhap N: '); readln(n);

writeln('Bang cuu chuong ',n,' : '); 

for i:=1 to 10 do writeln(n,' x ',i,' = ',n*i);

if n mod 2=0 then writeln(n,'  la so chan ') else writeln(n,' la so le');

d:=0;

for i:=1 to n do if n mod i=0 then d:=d+1;

if d=2 then write(n,' la so nguyen to') else write(n,' khong phai la so nguyen to');

readln

end.

Bình luận (0)
Phạm tuyết nhung
Xem chi tiết
krt-ttt
31 tháng 10 2021 lúc 20:09

python.

N = input(nhap so nguyen N)

if n%2 == 0:

      print('N la so chan')

else:

      print('N la so le')

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

#include <bits/stdc++.h>

using namespace std;

long long n;

int main()

{

cin>>n;

if (n%2!=0) cout<<"La so le";

else cout<<"Khong la so le";

return 0;

}

Bình luận (0)
Trần Long
Xem chi tiết
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)
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)
NGUYỄN LÊ XUÂN THỊNH
Xem chi tiết
Kiều Vũ Linh
23 tháng 2 2023 lúc 11:23

Bài 1

Var s,i:integer;

tb:real;

Begin

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

i:=1;

s:=0;

While i<=n do

Begin

s:=s+i;

i:=i+1;

End;

tb:=s/n;

Writeln('Tong la ',s);

Write('Trung binh la ',tb:10:2);

Readln;

End.

Bình luận (1)
Kiều Vũ Linh
23 tháng 2 2023 lúc 11:27

Bài 2

Var i,n,souoc:integer;

Begin

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

i:=1;

While i <= n do

Begin

i:=i + 1;

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

End;

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

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

Readln;

End.

Bình luận (1)