## factorial

#### OS/161 Reference Manual

### Name

factorial - compute factorials using execv

### Synopsis

`/testbin/factorial` N

### Description

`factorial` computes N!, for integer values N. It does the computation (in bignums) by recursively calling execv on itself and is thus useful for stressing your exec implementation.

Note that `factorial` does not make exec calls with large argv blocks; getting to numbers large enough that the size is interesting requires prohibitively many iterations and is exceedingly slow.

### Requirements

`factorial` uses the following system calls:

- write
- execv
- _exit

`factorial` should work once you have implemented the basic system calls, including of course execv. (But it depends on little other than execv, making it useful in the early stages.)

### Restrictions

Be aware that until you do the VM assignment and replace dumbvm, running a lot of execs will run the system out of memory very rapidly.