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

Bình luận (0)
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.

Bình luận (1)
Cao Ngọc Bảo Quyên
Xem chi tiết
Mạnh Quốc
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 2 2023 lúc 7:43

#include <bits/stdc++.h>

using namespace std;

int main()

{

int n;

cin>>n;

for (int i=1; i<=n; i++)

if (i%2==1) cout<<i<<" ";

return 0;

}

Bình luận (0)
Tiến
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 3 2021 lúc 20:03

uses crt;

var i,n,dem:integer;

begin

clrscr;

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

dem:=0;

for i:=1 to n do 

  if i mod 2=0 then 

begin

inc(dem);

write(i:4);

if dem=15 then writeln;

end;

readln;

end.

Bình luận (2)
Bùi Anh Tuấn
17 tháng 3 2021 lúc 20:08

Bình luận (0)
Nguyễn Thị Tươi
Xem chi tiết
NgocTuan
Xem chi tiết
Lê Chiêu Nguyên	Vũ
4 tháng 4 2023 lúc 10:11

program Min;
uses crt;
var i,n:integer;
begin
   clrscr;
   write('Nhap n: '); readln(n);
   write('Cac so le nho hon hoac bang ',n,'la :');
   for i:=1 to n do if i mod 2 = 1 then write(i:4);
   readln
end.

Bình luận (0)
Như Ý
Xem chi tiết
Phía sau một cô gái
1 tháng 5 2023 lúc 19:27

Câu 1:

program Tinhtong:

var

     n, i, sum: integer;

begin

     write('Nhap n: ');

     readln(n);

     sum := 0;

     for i := 2 to n do

     begin

          if i mod 2 = 0 then

          begin

               sum := sum + i;

          end;

     end;

     writeln('Tong cac so chan tu 2 toi ', n, ' la ', sum);

     readln; 

end.

Câu 2:

program Tinhtong:

var

     n, i, sum: integer;

begin

     write('Nhap n: ');

     readln(n);

     sum := 0;

     for i := 1 to n do

     begin

          if i mod 2 = 1 then

          begin

               sum := sum + i;

          end;

     end;

     writeln('Tong cac so le tu 1 toi ', n, ' la ', sum);

     readln;

end.

Bình luận (1)
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;

}

Bình luận (0)
tâm 8a3
Xem chi tiết