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.
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;
}
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
cin>>n;
if (n%2==0) cout<<"YES";
else cout<<"NO";
return 0;
}
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.
bài 1:
program tinhtong;
uses crt;
var n,s,i:longint;
begin
clrscr;
repeat
write('nhap so n:');readln(n);
until (n>=10)and(n<100);
s:=0;
for i:=10 to n do
if (i mod 2)=0 then s:=s+i;
write('tong cua cac so co hang don vi chan la:',s);
readln;
end.
bài 2:
program kiem_tra_so_nguyen_to;
uses crt;
var n,j,i:longint;
begin
clrscr;
write('nhap so n:');readln(n);
j:=0;
for i:=1 to n do
if (n mod i)=0 then j:=j+1;
if j=2 then write(n,'la so nguyen to')
else write(n,'khong phai la so nguyen to');
readln;
end.
Cách khác:
Bài 2:
uses crt;
var n,i,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
if n>1 then
begin
kt:=0;
for i:=2 to n-1 do
if n mod i=0 then kt:=1;
if kt=0 then writeln(n,' la so nguyen to')
else writeln(n,' la hop so');
end
else writeln(n,' khong la so nguyen to cung khong la hop so');
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.
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.
2:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,i,kt=0;
cin>>n;
for (int i=2; i*i<=n; i++)
if (n%i==0) kt=1;
if (kt==0) cout<<"YES";
else cout<<"NO";
}
uses crt;
var n,i,kt:integer;
begin
clrscr;
readln(n);
kt:=0;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then kt:=1;
if (kt=0) and (n>1) then write('phai')
else write('Khong phai');
readln;
end.
Xác định bài toán:
+ Input là điều kiện cho trước
+ Output là kết quả cần thu được.
Đáp án: A