RosettaCodeData/Task/Evaluate-binomial-coefficients/Fortran/evaluate-binomial-coefficients-1.f
2020-02-17 23:21:07 -08:00

31 lines
519 B
Forth

program test_choose
implicit none
write (*, '(i0)') choose (5, 3)
contains
function factorial (n) result (res)
implicit none
integer, intent (in) :: n
integer :: res
integer :: i
res = product ((/(i, i = 1, n)/))
end function factorial
function choose (n, k) result (res)
implicit none
integer, intent (in) :: n
integer, intent (in) :: k
integer :: res
res = factorial (n) / (factorial (k) * factorial (n - k))
end function choose
end program test_choose