30 lines
417 B
Plaintext
30 lines
417 B
Plaintext
for n = 0 to 14
|
|
for k = 0 to n
|
|
print rjust(binomial(n, k), 5);
|
|
next k
|
|
print
|
|
next n
|
|
end
|
|
|
|
function factorial(n)
|
|
if n < 1 then return 1
|
|
|
|
product = 1
|
|
for i = 2 to n
|
|
product *= i
|
|
next
|
|
|
|
return product
|
|
end function
|
|
|
|
function binomial(n, k)
|
|
if n < 0 or k < 0 or n <= k then return 1
|
|
|
|
product = 1
|
|
for i = n - k + 1 to n
|
|
product *= i
|
|
next
|
|
|
|
return int(product / factorial(k))
|
|
end function
|