Mercurial > hg > Papers > 2019 > oshiro-thesis
annotate final_pre/src/factrial.cbc @ 7:0e8b9646d43f
add final_pre
author | e155702 |
---|---|
date | Sun, 17 Feb 2019 05:39:59 +0900 |
parents | |
children |
rev | line source |
---|---|
7 | 1 __code print_factorial(int prod) |
2 { | |
3 printf("factorial = %d\n", prod); | |
4 exit(0); | |
5 } | |
6 | |
7 __code factorial0(int prod, int x) | |
8 { | |
9 if (x >= 1) { | |
10 goto factorial0(prod*x, x-1); | |
11 } else { | |
12 goto print_factorial(prod); | |
13 } | |
14 | |
15 } | |
16 | |
17 __code factorial(int x) | |
18 { | |
19 goto factorial0(1, x); | |
20 } | |
21 | |
22 int main(int argc, char **argv) | |
23 { | |
24 int i; | |
25 i = atoi(argv[1]); | |
26 | |
27 goto factorial(i); | |
28 } | |
29 |