]> git.cameronkatri.com Git - mandoc.git/blob - regress/roff/de/factorial.in
If a user-defined macro is aborted because it exceeds the stack
[mandoc.git] / regress / roff / de / factorial.in
1 .Dd December 30, 2014
2 .Dt FACTORIAL 1
3 .Os OpenBSD
4 .Sh NAME
5 .Nm factorial
6 .Nd factorial sequence
7 .Sh DESCRIPTION
8 .\" recursively calculate a single factorial
9 .de rfac
10 . ie \\$1>1 \{\
11 . No \\$1 *
12 . nr i \\$1-1
13 . rfac \\ni
14 . nr acc \\n[acc]*\\$1
15 . \}
16 . el .nr acc 1
17 ..
18 .\" recursively print a sequence of factorials
19 .de fac
20 . No \\$1! =
21 . rfac \\$1
22 . if \\$1>1 1 =
23 . No \\n[acc]
24 . if \\$1 \{\
25 . br
26 . nr i \\$1-1
27 . fac \\ni
28 . \}
29 ..
30 .\" main program
31 .fac 9