home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / compcomp / awk / fact.awk < prev    next >
Encoding:
Text File  |  1990-06-04  |  197 b   |  12 lines

  1. # calculate and print the factorial of the input
  2.  
  3. function factorial(n) {
  4.     if (n <= 1)
  5.         return 1
  6.     else
  7.         return n * factorial(n - 1)
  8. }
  9. {
  10.     print $1, factorial($1)
  11. }
  12.