✔ 最佳答案
N factorial is defined as :
N! = 1 X 2 X 3 X . . . X N
The following is a simple program written in tpw using "repeat . . . until" for your reference :
uses wincrt;
var
n, i, fact : real;
begin
write('Input a positive integer: ');
readln(n);
i:=0;
fact:=1;
repeat
i:=i+1;
fact:=fact*i;
until i=n;
writeln(n:1:0, '! = ', fact:1:0);
end.
If you really want to find the value of 1 + 2 + 3 + . . . + N,
then change fact:=1; to fact:=0;
and change fact:=fact*i; to fact:=fact+i;