summaryrefslogtreecommitdiff
path: root/ipl/procs/pascal.icn
blob: 92da5ef262f81238e8a96992cc2f072e2e77b58c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
############################################################################
#
#	File:     pascal.icn
#
#	Subject:  Procedure to write Pascal triangles
#
#	Author:   Ralph E. Griswold
#
#	Date:     August 3, 2000
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This procedure writes numeric triangles as "carpets".
#
#  The argument determines the number of rows written, default 16.
#
############################################################################
#
#  Requires:  large integers
#
############################################################################
#
#  Links:  math
#
############################################################################

link math

#  The Pascal Triangle

procedure pascal(n)		#: Pascal triangle
   local i, j

   /n := 16

   write("width=", n, " height=", n)	# carpet header

   every i := 0 to n - 1 do {
      every j := 0 to n - 1 do
         writes(binocoef(i, j) | 0, " ")
      write()
      }

end