Mercurial > hg > Papers > 2010 > kent-master
annotate paper/sources/factorial.cbc @ 10:3d9addf62d0b
organized repository.
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 16 Feb 2010 14:35:36 +0900 |
parents | |
children |
rev | line source |
---|---|
10 | 1 code print_factorial(int prod) { |
2 printf("factorial = %d\n", prod); | |
3 exit(0); | |
4 } | |
5 | |
6 code factorial0(int prod, int x) { | |
7 if (x >= 1) { | |
8 goto factorial0(prod*x, x-1); | |
9 } else { | |
10 goto print_factorial(prod); | |
11 } | |
12 } | |
13 | |
14 code factorial(int x) { | |
15 goto factorial0(1, x); | |
16 } | |
17 | |
18 int main(int argc, char **argv) { | |
19 int i; | |
20 i = atoi(argv[1]); | |
21 | |
22 goto factorial(i); | |
23 } | |
24 |