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.
program tim_uoc;
uses crt;
var i,n,tong:integer;
begin
clrscr;
write('nhap so n:');readln(n);
i:=1;tong:=0;
writeln('cac uoc cua ',n,' la:');
while i<=n do
if n mod i=0 then
begin
write(i:3);
inc(i);
end;
writeln;
i:=1;writeln('cac uoc chan:');
while i<=n do
begin
if n mod i=0 then
begin
if i mod 2=0 then write(i:3);
tong:=tong+i;
end;
end;
writeln;
write('tong cac uoc chan:',tong);
readln;
end.
uses crt;
var n,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
i:=1;
writeln('Cac uoc cua ',n,' la: ');
while i<=n do
begin
if n mod i=0 then write(i:4):
i:=i+1;
end;
writeln;
writeln('Cac uoc chan cua ',n,' la: ');
t:=0;
i:=1;
while i<=n do
begin
if (n mod i=0) then
begin
t:=t+i;
write(i:4);
end;
inc(i);
end;
writeln('Tong cac uoc chan cua ',n,' la: ',t);
readln;
end.
uses crt;
var n,i,kt,j:integer;
begin
clrscr;
readln(n);
i:=1;
while (i<n) do
begin
i:=i+1;
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.
program bai_1;
uses crt;
var i,n,j,d,dem:word;
begin
clrscr;
repeat
write('nhap n:');readln(n);
if (n<=0)or(n>=10000)then writeln('so ban nhap khong hop le, ban hay nhap lai:');
until (n>0)and(n<10000);
writeln('cac uoc so la so tu nhien cua ',n,' la:');
for i:=1 to n do
if n mod i=0 then write(i,' ');
writeln;
dem:=0;
for i:=2 to n do
begin
d:=0;
for j:=2 to i div 2 do
if i mod j=0 then inc(d);
if (d=0)and(n mod i=0)then inc(dem);
end;
if dem>0 then writeln('cac uoc so la so nguyen to cua ',n,' la:');
begin
d:=0;
for j:=2 to i div 2 do
if i mod j=0 then inc(d);
if (d=0)and(n mod i=0)then write(i,' ');
end;
if dem=0 then write(0);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long i,n,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
if (n%i==0)
{
cout<<i<<" ";
dem++;
}
cout<<endl;
cout<<dem;
return 0;
}
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.
program TinhTongVaUocCuaTong;
var a, b, tong, i: integer;
SoNguyenTo: boolean;
begin
writeln('Nhap vao hai so a va b (a > 0, b > 0): ');
write('a = ');
readln(a);
write('b = ');
readln(b);
tong := a + b;
writeln('Tong cua a + b = ', tong);
writeln('Uoc cua tong a + b: ');
for i := 1 to tong do
begin
if tong mod i = 0 then
writeln(i);
end;
SoNguyenTo := true;
if tong < 2 then
SoNguyenTo := false
else
for i := 2 to trunc(sqrt(tong)) do
begin
if tong mod i = 0 then
begin
SoNguyenTo := false;
break;
end;
end;
if SoNguyenTo then
writeln('Tong a + b la so nguyen to:')
else
writeln('Tong a + b khong phai la so nguyen to:');
end.
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.
var i,n,s,du,dem:integer;
Begin
While n<=0 do
Begin
Write('N = ');readln(n);
End;
For i:=1 to n do
If n mod i = 0 then
Begin
Write(i:7);
du:=du+1;
s:=s+i;
End;
Writeln('So uoc cua ',n,' la ',du);
Writeln('Tong cac uoc cua ',n,' la ',s);
For i:=1 to s do
If s mod i = 0 then dem:=dem+1;
If dem=2 then write(s,' la so nguyen to')
Else write(s,' khong la so nguyen to');
Readln;
End.
Cám ơn nhiều