Những câu hỏi liên quan
nam bảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 2 2022 lúc 13:44

uses crt;

var n,m,i,dem,t,t1,d1:integer;

//chuongtrinhcon

function ktnt(var n:integer):boolean;

var i:integer;

kt:boolean;

begin

kt:=true;

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

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

if (kt=true) then ktnt:=true

else ktnt:=false;

end;

//chuongtrinhchinh

begin

clrscr;

readln(n,m);

if (ktnt(n)=true) then writeln(n,' la so nguyen to')

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

dem:=0;

t:=0;

for i:=2 to n do 

  if (ktnt(i)=true) then

begin

write(i:4);

t:=t+i;

dem:=dem+1;

end;

writeln;

writeln(t,' ',dem);

t1:=0;

d1:=0;

for i:=n to m do 

  if ktnt(i)=true then

begin

write(i:4);

t1:=t1+i;

inc(d1);

end;

writeln;

writeln(t1,' ',d1);

readln;

end.

Bình luận (0)
Trần Long
Xem chi tiết
Ngô Thị Tân
Xem chi tiết
datcoder
7 tháng 1 lúc 21:10

function nt(x: integer): boolean;

var j: integer;

begin

nt:=true;

if (x=2) or (x=3) then exit;

nt:=false;

if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;

j:=5;

while j<=trunc(sqrt(x)) do

begin

if (x mod j=0) or (x mod (j+2)=0) then exit;

j:=j+6;

end;

nt:=true;

end;

Bình luận (0)
Trần Long
Xem chi tiết
Trần thị bảo ly
Xem chi tiết
Kiều Vũ Linh
11 tháng 3 2023 lúc 13:34

Var i,n,d:integer;

Begin

Write('Nhap so can kiem tra ');readln(n);

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 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)
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)
Lê Thành Đô
Xem chi tiết
Luân Đào
29 tháng 12 2020 lúc 18:12

uses crt;

var i,n,s: integer;

a:array[1..100] of integer;

begin

writeln('Nhap n: '); read(n);

for i:=1 to n do 

begin

write('a[',i,'] = '); readln(a[i]);

end;

writeln('Cac so le: ')

s:=0;

for i:=1 to n do

if a[i] mod 2 <> 0 then 

begin

s:=s+a[i];

write(a[i],' ');

end;

writeln('- Tong so le: ',s);

for i:=1 to trunc(sqrt(s)) do if s mod i = 0 then d:=d+1;

if d > 1 then writeln('Tong do khong la so nguyen to') else writeln('Tong do 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)