program TinhTongGiaiThua;
uses crt;
var
n, num, sum, digitCount: integer;
function GiaiThua(x: integer): integer;
var
i, fact: integer;
begin
fact := 1;
for i := 1 to x do
begin
fact := fact * i;
end;
GiaiThua := fact;
end;
begin
clrscr;
write('Nhap so n: ');
readln(n);
sum := 0;
digitCount := 0;
while n > 0 do
begin
num := n mod 10;
sum := sum + GiaiThua(num);
digitCount := digitCount + 1;
n := n div 10;
end;
writeln('Tong giai thua cac chu so cua n la: ', sum);
writeln('Tong so chu so cua n la: ', digitCount);
readln;
end.