0
|
1 #include "stdio.h"
|
572
|
2 code print();
|
0
|
3 int
|
|
4 main(ac,av)
|
|
5 int ac;
|
|
6 char *av[];
|
|
7 {
|
|
8 int n;
|
172
|
9 // n = atoi(av[1]);
|
|
10 n = 10;
|
0
|
11 goto factorial(n,1,n,print,return,environment);
|
|
12 }
|
|
13
|
|
14 code print(n,result,orig,print,exit1,exit1env)
|
|
15 int n,result,orig;
|
|
16 code (*print)(),(*exit1)();
|
|
17 void *exit1env;
|
|
18 {
|
427
|
19 printf("#0018:%d! = %d\n",n, result);
|
172
|
20 goto (*exit1)(0),exit1env;
|
0
|
21 }
|
|
22
|
|
23 code factorial(n,result,orig,print,exit1,exit1env)
|
|
24 int n,result,orig;
|
|
25 code (*print)();
|
|
26 code (*exit1)();
|
|
27 void *exit1env;
|
|
28 {
|
|
29 if (n<0) {
|
427
|
30 printf("#0029:err %d!\n",n);
|
0
|
31 goto (*exit1)(0),exit1env;
|
|
32 }
|
|
33 if (n==0)
|
7
|
34 goto (*print)(n,result,orig,print,exit1,exit1env);
|
|
35 /* goto print(n,result,orig,print,exit1,exit1env); */
|
0
|
36 else {
|
|
37 result *= n;
|
|
38 n--;
|
|
39 goto factorial(n,result,orig,print,exit1,exit1env);
|
|
40 }
|
|
41 }
|