2 * This simple classical example of recursion is useful for
3 * testing stack backtraces and such.
10 /* VxWorks does not supply atoi. */
17 while (*z
>= '0' && *z
<= '9')
18 i
= i
* 10 + (*z
++ - '0');
22 /* I don't know of any way to pass an array to VxWorks. This function
23 can be called directly from gdb. */
25 void vxmain (char *arg
)
32 main (2, argv
, (char **) 0);
38 #endif /* ! vxworks */
40 int main (int argc
, char *argv
[], char **envp
)
42 char *argv[], **envp;*/
50 printf ("%d\n", factorial (1));
53 printf ("usage: factorial <number>\n");
56 printf ("%d\n", factorial (atoi (argv
[1])));
62 int factorial (int value
)
68 value
*= factorial (value
- 1);