Bạn chưa đăng nhập. Vui lòng đăng nhập để hỏi bài

Những câu hỏi liên quan
Gà Công Nghệ
Xem chi tiết
Anh Phạm
28 tháng 8 2021 lúc 19:43

uses crt;

var n,i,o,d:integer;

function ktnt(n:integer): integer;

var i,d:integer;

begin

d:=0;

for i:=1 to sqrt(n) do

if (n mod i=0) then d:=d+1;

if d=2 then ktnt=0

else ktnt=1;

end;

begin

readln(n);

writeln(' so nguyen to be hon hoac bang n la'); {a}

for i:=1 to n do

if ktnt(i)=0 then writeln(i);

writeln('so nguyen to nho nhat khong be hon n');

o:=n;

while o>0 do

begin

if ktnt(o)=0 then

begin

write(o);

break;

end;

o:=o+1;

end;

writeln('cặp số nguyên tố là hai số nguyên lẻ liên tiếp nhỏ hơn hoặc bằng n');

o:=0;

o:=1;

d:=0;

for i:=o+2 to n do

begin

if ktnt(i)=0 then

begin

d:=d+1;

write(i,' ');

if d<2 then continue;

end;

d:=0;

writeln;

end;

readln;

end.

nguyễn an phát
Xem chi tiết
Nguyễn Lê Phước Thịnh
19 tháng 3 2021 lúc 19:52

a)

uses crt;

var n,i,kt,j:integer;

begin

clrscr;

repeat

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

until n>1;

writeln('Cac so nguyen to be hon hoac bang ',n,' la: ');

for i:=2 to n do 

begin

kt:=0;

for j:=2 to i-1 do 

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

if kt=0 then write(i:4);

end;

readln;

end.

Phan Đức Duy
Xem chi tiết
hacker
10 tháng 1 2021 lúc 17:31

uses crt;var n: longint;    chrn: string;    valn,sum,max,i,preperror: byte;begin    write('Nhap so can kiem tra: ');    readln(n);    str(n,chrn);    for i:=1 to length(chrn) do    begin        val(chrn[i],valn,preperror);        sum:=sum+valn;        if max<valn then max:=valn;        valn:=0    end;    writeln('Ket qua: ');    writeln(length(chrn));    writeln(sum);    write(max);    readln;end.uses crt;var n: longint;    chrn: string;    valn,sum,max,i,preperror: byte;begin    write('Nhap so can kiem tra: ');    readln(n);    str(n,chrn);    for i:=1 to length(chrn) do    begin        val(chrn[i],valn,preperror);        sum:=sum+valn;        if max<valn then max:=valn;        valn:=0    end;    writeln('Ket qua: ');    writeln(length(chrn));    writeln(sum);    write(max);    readln;end.

Minh Lệ
10 tháng 1 2021 lúc 20:09

Program HOC24;

var N:longint;

max,tg,t,d: integer;

Begin

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

max:=0;

while n<>0 do

begin

tg:=n mod 10;

d:=d+1;

t:=t+tg;

if tg>max then max:=tg;

n:=n div 10;

end;

writeln('So nguyen N co ',d,' chu so');

writeln('Tong cac chu so cua N la : ',t);

write('Chu so lon nhat cua N la :',max);

readln

end.

Nguyễn Lê Phước Thịnh
10 tháng 1 2021 lúc 20:11

uses crt;

var n,d,i,t,max,x:longint;

y:integer;

st:string;

begin

clrscr;

repeat

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

until n>0;

str(n,st);

d:=length(st);

writeln('So chu so cua ',n,' la: ',d);

t:=0;

max:=0;

for i:=1 to d do 

  begin

val(st[i],x,y);

t:=t+x;

if max<x then max:=x;

end;

writeln('Tong cac chu so cua ',n,' la: ',t);

writeln('Chu so lon nhat cua ',n,' la: ',max);

readln;

end.

Lily Minamoto
Xem chi tiết
nguyễn an phát
26 tháng 5 2021 lúc 11:36

program so_nguyen_to;

uses crt;

var i,n:integer;

function kt(n:integer):boolean;

var i,j:integer;

begin

j:=0;

for i:=1 to n do

if n mod i=0 then inc(j);

if j=2 then kt:=true

else kt:=false;

end;

BEGIN

clrscr;

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

if kt(n) then writeln(n,' la so nguyen to')

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

writeln('cac so nguyen to be hon hoac bang ',n,' la:');

for i:=1 to n do

if kt(i) then write(i:5);

writeln;

writeln('cac cap so le lien tiep la so nguyen to be hon hoac bang ',n,' la:');

for i:=1 to n do

if (i mod 2=1) and (kt(i)) and (kt(i+2)) then write(i,',',i+2);

readln;

end.

nguyễn an phát
26 tháng 5 2021 lúc 11:39

câu c bạn viết cách ra nhé!

Kisaragi Saya
Xem chi tiết
Đỗ Tuệ Lâm
17 tháng 2 2022 lúc 7:10

{program bt_1;
uses crt;
Var:S ,n, i, j:longint;
Begin 
  clrsr;
  Write('Nhap n');Readln(n);
    For i:=1 to n do
    Begin
      S:=0;
      For j:=0 to i do
      if i mod j:=0 then S:=S+j;
      if S=2*i then Write (i:5);
    end;
readln;
end.
}

Lưu Nguyễn Hải Nam
6 tháng 12 2023 lúc 18:54

PASSCAL HAY???

 

Lê Tâm Anh
Xem chi tiết
gấu béo
7 tháng 5 2023 lúc 19:20

program Le_Nho_Hon_Hoac_Bang_n;

uses crt;

var

       n, i: integer;

begin

       clrscr;

       write('Nhap vao mot so nguyen duong n: ');

       readln(n);

       while n <= 0 do

       begin

              writeln('So ban nhap khong hop le. Xin vui long nhap lai: ');

              readln(n);

       end;

       clrscr;

       writeln('Cac so le nho hon hoac bang ', n, ' la:');

       i := 1;

       while i <= n do

       begin

              if i mod 2 <> 0 then

                     writeln(i);

              i := i + 1;

       end;

       readln;

end.

ksie
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 1 2022 lúc 15:11

uses crt;

var n,i,dem,j,t:integer;

kt:boolean;

begin

clrscr;

readln(n);

t:=0;

for i:=2 to n do 

begin

kt:=true;

for j:=2 to i-1 do 

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

if kt=true then 

begin

write(i:4);

t:=t+i;

end;

end;

writeln;

writeln(t);

readln;

end.

trần hoàng
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 4 2022 lúc 21:53

#include <bits/stdc++.h>

using namespace std;

long long i,n,kt,j;

int main()

{

cin>>n;

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

{

kt=0;

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

if (i%j==0) kt=1;

if (kt==0) cout<<i<<" ";

}

return 0;

}

Lưu Thùy Linh
Xem chi tiết
Nguyễn Hoàng Duy
29 tháng 3 2023 lúc 15:28

program TinhTongSoTuNhienLe;
var
  N, i, sum: integer;
begin
  write('Nhap so N: ');
  readln(N);

  sum := 0;
  for i := 1 to N do
  begin
    if i mod 2 = 1 then // Kiểm tra số lẻ
      sum := sum + i;   // Cộng dồn vào tổng
  end;

  writeln('Tong cac so tu nhien le nho hon hoac bang N la: ', sum);
  readln;
end.

lân đinh
Xem chi tiết
Nguyễn Lê Phước Thịnh
11 tháng 5 2021 lúc 10:50

Bài 3:

uses crt;

var i:integer;

{------------------chuong-trinh-con-kiem-tra-so-nguyen-to----------------------}

function ktnt(x:integer):boolean;

var kt:boolean;

i:integer;

begin

kt:=true;

for i:=2 to x-1 do

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

if kt=true then ktnt:=true

else ktnt:=false;

end;

{-------------------------chuong-trinh-chinh----------------------------}

begin

clrscr;

for i:=2 to 9999 do 

  if (ktnt(i)=true) and (ktnt(i+2)=true) then 

begin

writeln(i,',',i+2);

delay(500);

end;

readln;

end.

Nguyễn Lê Phước Thịnh
11 tháng 5 2021 lúc 10:56

Bài 4: 

uses crt;

var a,b,c,kt:integer;

begin

clrscr;

write('Nhap ngay:'); readln(a);

write('Nhap thang:'); readln(b);

write('Nhap nam:'); readln(c);

kt:=0;

if (b=1) and (0<a) and (a<=31) then kt:=1;

if (b=2) and (0<a) and (a<=28) then kt:=1;

if (b=2) and (0<a) and (a<=29) and (c mod 4=0) then kt:=1;

if (b=3) and (0<a) and (a<=31) then kt:=1;

if (b=4) and (0<a) and (a<=30) then kt:=1;

if (b=5) and (0<a) and (a<=31) then kt:=1;

if (b=6) and (0<a) and (a<=30) then kt:=1;

if (b=7) and (0<a) and (a<=31) then kt:=1;

if (b=8) and (0<a) and (a<=31) then kt:=1;

if (b=9) and (0<a) and (a<=30) then kt:=1;

if (b=10) and (0<a) and (a<=31) then kt:=1;

if (b=11) and (0<a) and (a<=30) then kt:=1;

if (b=12) and (0<a) and (a<=31) then kt:=1;

if kt=0 then writeln('Khong hop le')

else writeln('Hop le');

readln;

end.

Lê Thị Cẩm Tiên
9 tháng 7 2021 lúc 10:30

Bạn ơi bạn làm ra bài 3 chưa, cho mình xin cách làm nữa.

Python