home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / dos / prg / sphinx / examples / other / factor.c__ < prev    next >
Encoding:
Text File  |  1993-05-14  |  381 b   |  22 lines

  1. /*
  2.     SPHINX C-- example program of procedure declaration and recursion. 
  3. */
  4.  
  5. ?include "WRITE.H--"
  6.  
  7.  
  8. word factorial( word number )    /* range of 1 to 8 before overflow */
  9. {
  10. IF( number == 1 )
  11.     return( 1 );
  12. ELSE return( factorial( number-1 ) * number );
  13. }
  14.  
  15.  
  16. main ()
  17. {
  18. WRITESTR("The factorial of 8 is ");
  19. WRITEWORD( factorial(8) );
  20. }
  21.  
  22. /* end of FACTOR.C-- */