![](https://rs.olm.vn/images/avt/0.png?1311)
Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
![](https://rs.olm.vn/images/avt/0.png?1311)
![](https://rs.olm.vn/images/avt/0.png?1311)
1: VCT pascal kiểm tra số n có phải là số nguyên tố không
uses crt;
var n,i,kt:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if n<=1 then writeln('ban da nhap sai,yeu cau ban nhap lai');
until n>1;
kt:=0;
for i:=2 to n-1 do
if n mod i=0 then
begin
kt:=1;
break;
end;
if kt=0 then writeln(n,' la so nguyen to')
else writeln(n,' khong la so nguyen to');
readln;
end.
2:VCT pascal kiểm tra số n có phải là số hoàn hảo không
uses crt;
var n,i,t:integer;
begin
clrscr;
write('nhap n:'); readln(n);
t:=0;
for i:=1 to n-1 do
if n mod i=0 then begin
t:=t+i;
end;
if t=n then writeln(n,' la so hoan hao')
else write(n,' khong la so hoan hao');
readln;
end.
3:VCT pascal kiểm tra số n xuất ra màn hình các số nguyên tố từ 2 đến n
uses crt;
var n,i,kt,j:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if n<=2 then writeln('ban da nhap sai, yeu cau ban nhap lai');
until n>2;
writeln('day cac so nguyen to trong khoang tu 2 toi ',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.
![](https://rs.olm.vn/images/avt/0.png?1311)
Câu 58:
Var n:integer;
Begin
Write('n = ');readln(n);
If n mod 2 <> 0 then write(n,' la so le')
Else write(n,' khong la so le');
Readln
End.
Câu 61:
Var n:integer;
Begin
Write('n = ');readln(n);
If n mod 2 = 0 then write(n,' la so chan')
Else write(n,' khong la so chan');
Readln
End.
![](https://rs.olm.vn/images/avt/0.png?1311)
1 không
2
Program UCLN;
uses crt;
var a,b : integer;
begin
write ('nhap so a la ');readln (a);
write ('nhap so b la ');readln (b);
while a < > b do
if a >b then a := a - b else b := b - a ;
write ( ' UCLN la :' , a );
readln
end.
1:
#include <bits/stdc++.h>
using namespace std;
int n,i;
bool kt;
int main()
{
cin>>n;
kt=true;
for (i=2; i*i<=n; i++)
if (n%i==0) kt=false;
if (kt==true && n>1) cout<<"La so nguyen to";
else cout<<"Khong la so nguyen to";
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long n,i;
bool kt;
int main()
{
cin>>n;
if (n>1)
{
kt=true;
for (i=2; i*i<=n; i++)
if (n%i==0) kt=false;
if (kt==true) cout<<n<<" la so nguyen to";
else cout<<n<<" khong la so nguyen to";
}
else cout<<n<<" khong la so nguyen to";
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
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à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.
![](https://rs.olm.vn/images/avt/0.png?1311)
Uses crt;
var n,i,z: integer;
begin clrscr;
readln(n);
for i:=1 to n do if(n mod i=0) then z:=z+1;
if(z=2) then writeln(z,' la so nguyen to')
else writeln(z,' khong phai la so nguyen to');
readln;
end.
program PrimeNumber;
uses crt;
var
N, i: integer;
isPrime: boolean;
begin
clrscr;
write('Enter N: ');
readln(N);
if N <= 1 then
begin
writeln('N is not a prime number');
end
else
begin
isPrime := true;
for i := 2 to trunc(sqrt(N)) do
begin
if N mod i = 0 then
begin
isPrime := false;
break;
end;
end;
if isPrime then
begin
writeln('N is a prime number');
end
else
begin
writeln('N is not a prime number');
end;
end;
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
program TinhTongVaUocSo;
var
a, b, tong, i: integer;
laSoNguyenTo: boolean;
begin
write('Nhap a: ');
readln(a);
write('Nhap b: ');
readln(b);
tong := a + b;
writeln('Tong cua a va b la: ', tong);
writeln('Uoc so cua tong la:');
for i := 1 to tong do
begin
if tong mod i = 0 then
writeln(i);
end;
laSoNguyenTo := true;
if tong < 2 then
laSoNguyenTo := false
else
for i := 2 to trunc(sqrt(tong)) do
if tong mod i = 0 then
begin
laSoNguyenTo := false;
break;
end;
if laSoNguyenTo then
writeln('Tong a va b la so nguyen to')
else
writeln('Tong a va b khong phai la so nguyen to');
readln;
end.
var i,n:integer;
begin
write('n = ');readln(n);
i:=2;
while n mod i <> 0 do i:=i+1;
if i = n then write(n,' la so nguyen to')
else write(n,' khong la so nguyen to');
readln
end.
Uses crt;
var i,n,p: integer;
begin clrscr;
readln(n);
for i:=1 to n do if(n mod i=0) then p:=p+1;
if(p=2) then writeln(n,' la so nguyen to')
else writeln(n,' khong phai la so nguyen to');
readln;
end.