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. */
32 main (2, argv
, (char **) 0);
38 #endif /* ! vxworks */
44 main (int argc
, char **argv
, char **envp
)
47 main (argc
, argv
, envp
)
57 printf ("%d\n", factorial (1));
60 printf ("usage: factorial <number>\n");
63 printf ("%d\n", factorial (atoi (argv
[1])));
70 int factorial (int value
)
72 int factorial (value
) int value
;
78 value
*= factorial (value
- 1);