OS/161 Reference Manual


factorial - compute factorials using execv


/testbin/factorial N


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.


factorial uses the following system calls:

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.)


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.