uses crt;
var n,i,s,kt,j,t:longint;
begin
clrscr;
write('Nhap n='); readln(n);
s:=1;
for i:=1 to n do
s:=s*i;
t:=0;
for i:=2 to s do
if s mod i=0 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('Tong cac uoc nguyen to cua n,'! la: ',t);
readln;
end.
ta dinh nghia nhu sau
n!=n*(n-1)*(n-2)*...*1;
vs 4!=1*2*3*4;
vi the ban chi can tinh tong cac so nguyen to tu 1 den n thoi
ko can tinh n! lam j cho mat tg ,do phuc tap la O(n) nhe