Bài 1:
program nguyen_to;
uses crt;
var n,m,i:integer;
{---Ham-nguyen-to---}
function ktnt(k:integer):boolean;
var r:integer;
begin
ktnt:=false;
if k<2 then exit;
for r:=2 to trunc(sqrt(k)) do
if k mod r=0 then exit;
ktnt:=true;
end;
{---CT-chinh---}
BEGIN
clrscr;
write('Nhap n: '); readln(n);
write('Nhap m: '); readln(m);
for i:=n to m do
if ktnt(i) then write(i,' ');
readln;
end.
Bài 2:
program nguyen_to;
uses crt;
var m,i,d:integer;
{---Ham-nguyen-to---}
function ktnt(k:integer):boolean;
var r:integer;
begin
ktnt:=false;
if k<2 then exit;
for r:=2 to trunc(sqrt(k)) do
if k mod r=0 then exit;
ktnt:=true;
end;
{---CT-chinh---}
BEGIN
clrscr;
write('Nhap m: '); readln(m);
i:=2; d:=0;
while d<m do
begin
if ktnt(i) then
begin
write(i,' ');
d:=d+1;
end;
i:=i+1;
end;
readln;
end.
Bài 3:
program ntcn;
var m,n:integer;
{---Ham-ucln---}
function ucln(m,n:integer):integer;
begin
while m<>n do
if m>n then m:=m-n else n:=n-m;
ucln:=m;
end;
{---CT-chinh---}
BEGIN
clrscr;
write('Nhap m: '); readln(m);
write('Nhap n: '); readln(n);
if ucln(m,n)=1 then write('La hai so nguyen to cung nhau')
else write('Khong phai la hai so nguyen to cung nhau');
readln;
end.
Bài 1:
uses crt;
var m,n,i:longint;
function nt(a:longint):boolean;
var i:longint;
begin
i:=2;
while(a>1)and(a mod i<>0)do inc(i);
nt:=i=a;
end;
begin
clrscr;
write('Nhap n,m: ');readln(n,m);
write('Cac so nguyen to tu n den m: ');
for i:=n to m do if nt(i) then write(i,' ');
readln
end.
Bài 2:
uses crt;
var m,n,i:longint;
function nt(a:longint):boolean;
var i:longint;
begin
i:=2;
while(a>1)and(a mod i<>0)do inc(i);
nt:=i=a;
end;
begin
clrscr;
write('Nhap m: ');readln(m);
write('Co ',m,' so nguyen to dau tien la: ');
repeat
inc(i);
if nt(i) then begin write(i,' '); inc(n); end;
until n=m;
readln
end.
Bài 3:
uses crt;
var m,n:longint;
function ucln(a,b:longint):longint;
begin
ucln:=a;
while (a mod ucln<>0)or(b mod ucln<>0) do dec(ucln);
end;
begin
clrscr;
write('Nhap m,n: ');readln(m,n);
if ucln(n,m)=1 then writeln('m,n la so nguyen to cung nhau') else
writeln('m,n khong la so nguyen to cung nhau');
readln
end.
Tin học, tiếng Anh: informatics, tiếng Pháp: informatique, là một ngành khoa học chuyên nghiên cứu quá trình tự động hóa việc tổ chức, lưu trữ, xử lý và truyền dẫn thông tin của một hệ thống máy tính cụ thể hoặc trừu tượng (ảo). Với cách hiểu hiện nay, tin học bao hàm tất cả các nghiên cứu và kỹ thuật có liên quan đến việc mô phỏng, biến đổi và tái tạo thông tin.
Nguồn : Wikipedia - Bách khoa toàn thưLớp 8 - Năm thứ ba ở cấp trung học cơ sở, học tập bắt đầu nặng dần, sang năm lại là năm cuối cấp áp lực lớn dần nhưng các em vẫn phải chú ý sức khỏe nhé!
Nguồn : ADMIN :))Xem thêm tại https://loigiaisgk.com/cau-hoi or https://giaibtsgk.com/cau-hoi
Copyright © 2021 HOCTAPSGK