24 lines
517 B
Plaintext
24 lines
517 B
Plaintext
100 sub factorial(n)
|
|
110 if n < 1 then factorial = 1
|
|
120 product = 1
|
|
130 for i = 2 to n
|
|
140 product = product*i
|
|
150 next
|
|
160 factorial = product
|
|
170 end sub
|
|
180 sub binomial(n,k)
|
|
190 if n < 0 or k < 0 or n <= k then binomial = 1
|
|
200 product = 1
|
|
210 for i = n-k+1 to n
|
|
220 product = product*i
|
|
230 next
|
|
240 binomial = int(product/factorial(k))
|
|
250 end sub
|
|
260 for n = 0 to 14
|
|
270 for k = 0 to n
|
|
280 print using " ####"; binomial(n,k);
|
|
290 next k
|
|
300 print
|
|
310 next n
|
|
320 end
|