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.
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";
}
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long x,y;
int main()
{
cin >>x>>y;
cout<<x<<" "<<y;
swap(x,y);
cout<<x<<" "<<y;
return 0;
}
program bai_toan;
var
N, i, sum: integer;
begin
write('Nhap so N: ');
readln(N);
write('Cac uoc cua ', N, ' khong ke ', N, ' la: ');
for i := 1 to N - 1 do
if N mod i = 0 then
write(i, ' ');
writeln;
sum := 0;
for i := 1 to N - 1 do
begin
if N mod i = 0 then sum := sum + i;
end;
if sum = N then writeln(N, ' la so hoan hao')
else writeln(N, ' khong phai la so hoan hao');
writeln;
writeln('Tat ca so hoan hao trong pham vi 1 -> ', N, ' la:');
for i := 1 to N do
begin
sum := 0;
for j := 1 to i - 1 do
begin
if i mod j = 0 then sum := sum + j;
end;
if sum = i then writeln(i);
end;
readln;
end.
Cau 1:
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
cin>>n;
if (n>0 && n%5==0) cout<<"Phai";
else cout<<"Khong phai";
}
1:
uses crt;
var i,j,t,kt:integer;
begin
clrscr;
t:=0;
for i:=1 to 100 do
if i>1 then
begin
kt:=0;
for j:=2 to i-1 do
if i mod j=0 then kt:=1;
if kt=0 then t:=t+i;
end;
writeln(t);
readln;
end.
Câu 2:
*Viết chương trình:
uses crt;
var n,p,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for p:=2 to n-1 do
if n mod p=0 then t:=t+p;
writeln('Tong cac uoc that su cua ',n,' la: ',t);
readln;
end.
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 t:=t+i;
if t=n then writeln(n,' la so hoan chinh')
else writeln(n,' khong la so hoan chinh');
readln;
end.
program so_hoan_hao;
var
n, tong_uoc, i: integer;
begin
writeln('Nhap vao mot so nguyen duong n:');
readln(n);
tong_uoc := 0;
for i := 1 to n-1 do
begin
if n mod i = 0 then
tong_uoc := tong_uoc + i;
end;
if tong_uoc = n then
writeln('YES')
else
writeln('NO');
end.
Bài 1:
uses crt;
var i,n:integer;
p:int64;
begin
clrscr;
write('n='); readln(n);
if n>=1 then
begin
p:=1;
for i:=1 to n do
p:=p*i;
writeln('tich P=',p);
end
else writeln('vui long nhap lai');
readln;
end.
Bài 2:
uses crt;
var x,n,i:integer;
lt:int64;
begin
clrscr;
write('nhap co so x='); readln(x);
write('nhap so mu n='); readln(n);
if (x>0) and (n>0) then
begin
lt:=1;
for i:=1 to n do
lt:=lt*x;
writeln(x,'^',n,'=',lt);
end
else writeln('vui long nhap lai');
readln;
end.
Bài 3:
uses crt;
var i,n,t:integer;
begin
clrscr;
write('n='); readln(n);
if n>=2 then
begin
t:=0;
for i:=1 to n-1 do
if n mod i=0 then t:=t+i;
if t=n then writeln(n,' la so hoan hao')
else writeln(n,' khong la so hoan hao');
end
else writeln('vui long nhap lai');
readln;
end.
Bài 4:
uses crt;
var i,n,kt:integer;
begin
clrscr;
write('n='); readln(n);
if n>=2 then
begin
kt:=0;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then kt:=1;
if kt=0 then writeln(n,' la so nguyen to')
else writeln(n,' khong la so nguyen to');
end
else writeln('vui long nhap lai');
readln;
end.
Bài 5:
uses crt;
var i,n,t,j:longint;
begin
clrscr;
write('n='); readln(n);
if n>=2 then
begin
for i:=2 to n do
begin
t:=0;
for j:=1 to i-1 do
if i mod j=0 then t:=t+j;
if t=i then write(i,' ')
end;
end
else writeln('vui long nhap lai');
readln;
end.
Bài 6:
uses crt;
var i,n,kt,j:longint;
begin
clrscr;
write('n='); readln(n);
if n>=2 then
begin
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,' ')
end;
end
else writeln('vui long nhap lai');
readln;
end.
Bài 1:
uses crt;
var i,n:integer;
p:int64;
begin
clrscr;
write('n='); readln(n);
if n>=1 then
begin
p:=1;
for i:=1 to n do
p:=p*i;
writeln('tich P=',p);
end
else writeln('vui long nhap lai');
readln;
end.
Bài 2:
uses crt;
var x,n,i:integer;
lt:int64;
begin
clrscr;
write('nhap co so x='); readln(x);
write('nhap so mu n='); readln(n);
if (x>0) and (n>0) then
begin
lt:=1;
for i:=1 to n do
lt:=lt*x;
writeln(x,'^',n,'=',lt);
end
else writeln('vui long nhap lai');
readln;
end.
Bài 3:
uses crt;
var i,n,t:integer;
begin
clrscr;
write('n='); readln(n);
if n>=2 then
begin
t:=0;
for i:=1 to n-1 do
if n mod i=0 then t:=t+i;
if t=n then writeln(n,' la so hoan hao')
else writeln(n,' khong la so hoan hao');
end
else writeln('vui long nhap lai');
readln;
end.
Bài 4:
uses crt;
var i,n,kt:integer;
begin
clrscr;
write('n='); readln(n);
if n>=2 then
begin
kt:=0;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then kt:=1;
if kt=0 then writeln(n,' la so nguyen to')
else writeln(n,' khong la so nguyen to');
end
else writeln('vui long nhap lai');
readln;
end.
Bài 5:
uses crt;
var i,n,t,j:longint;
begin
clrscr;
write('n='); readln(n);
if n>=2 then
begin
for i:=2 to n do
begin
t:=0;
for j:=1 to i-1 do
if i mod j=0 then t:=t+j;
if t=i then write(i,' ')
end;
end
else writeln('vui long nhap lai');
readln;
end.
Bài 6:
uses crt;
var i,n,kt,j:longint;
begin
clrscr;
write('n='); readln(n);
if n>=2 then
begin
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,' ')
end;
end
else writeln('vui long nhap lai');
readln;
end.