34 lines
450 B
Plaintext
34 lines
450 B
Plaintext
for n = 0 to 14
|
|
for k = 0 to n
|
|
print binomial(n, k) using "####";
|
|
next k
|
|
print
|
|
next n
|
|
end
|
|
|
|
sub factorial(n)
|
|
local product, i
|
|
|
|
if n < 1 return 1
|
|
|
|
product = 1
|
|
for i = 2 to n
|
|
product = product * i
|
|
next
|
|
|
|
return product
|
|
end sub
|
|
|
|
sub binomial(n, k)
|
|
local product, i
|
|
|
|
if n < 0 or k < 0 or n <= k return 1
|
|
|
|
product = 1
|
|
for i = n - k + 1 to n
|
|
product = product * i
|
|
next
|
|
|
|
return int(product / factorial(k))
|
|
end sub
|