RosettaCodeData/Task/Factorial/PostScript/factorial-1.ps

13 lines
232 B
PostScript

/fact {
dup 0 eq % check for the argument being 0
{
pop 1 % if so, the result is 1
}
{
dup
1 sub
fact % call recursively with n - 1
mul % multiply the result with n
} ifelse
} def