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.
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,j:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
begin
t:=0;
for j:=1 to i div 2 do
if i mod j=0 then t:=t+j;
if t=i then write(i:4);
end;
readln;
end.
a)
uses crt;
var n,i,t,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 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:4);
end;
readln;
end.
b)
uses crt;
var gt:real;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
gt:=1;
for i:=1 to n do
gt:=gt*i;
writeln(gt:0:0);
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.
uses crt;
var a:array[1..100]of real;
i,n:integer;
min,t:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln('Gia tri nho nhat la: ',min:4:2);
t:=0;
for i:=1 to n do
if i mod 2=0 then t:=t+a[i];
writeln('Tong cac phan tu co chi so chan la: ',t:4:2);
readln;
end.
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.
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.