RosettaCodeData/Task/Factorial/PostScript/factorial-1.ps
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

12 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