home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / procs / pascal.icn < prev    next >
Text File  |  2000-08-03  |  1KB  |  49 lines

  1. ############################################################################
  2. #
  3. #    File:     pascal.icn
  4. #
  5. #    Subject:  Procedure to write Pascal triangles
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     August 3, 2000
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This procedure writes numeric triangles as "carpets".
  18. #
  19. #  The argument determines the number of rows written, default 16.
  20. #
  21. ############################################################################
  22. #
  23. #  Requires:  large integers
  24. #
  25. ############################################################################
  26. #
  27. #  Links:  math
  28. #
  29. ############################################################################
  30.  
  31. link math
  32.  
  33. #  The Pascal Triangle
  34.  
  35. procedure pascal(n)        #: Pascal triangle
  36.    local i, j
  37.  
  38.    /n := 16
  39.  
  40.    write("width=", n, " height=", n)    # carpet header
  41.  
  42.    every i := 0 to n - 1 do {
  43.       every j := 0 to n - 1 do
  44.          writes(binocoef(i, j) | 0, " ")
  45.       write()
  46.       }
  47.  
  48. end
  49.