RosettaCodeData/Task/Evaluate-binomial-coefficients/OxygenBasic/evaluate-binomial-coefficie...

39 lines
586 B
Plaintext

uses console
function factorial(n as integer) as integer
if n < 1 then return 1
single product = 1
int i
for i = 2 to n
product *= i
next
return product
end function
function binomial(n as integer, k as integer) as integer
if n < 0 or k < 0 or n <= k then return 1
single product = 1
int i
for i = n - k + 1 to n
product *= i
next
return product \ factorial(k)
end function
int n, k
for n = 0 to 14
for k = 0 to n
print binomial(n, k) " ";
next k
printl
next n
printl cr "Enter ..."
waitkey