Getting binomial coefficient of a number in Julia – binomial() Method

binomial()

   

n

   

Syntax: binomial(n::Integer, k::Integer) Parameters:
  • n: Specified number
  • k: Specified number
Returns: It returns the binomial coefficient .
Example 1:
# Julia program to illustrate 
# the use of binomial() method
  
# Getting the binomial coefficient
println(binomial(6, 4))
println(factorial(6) ÷ (factorial(6-4) * factorial(4)))

                    
Output:
15
15
Example 2:
# Julia program to illustrate 
# the use of binomial() method
  
# Getting the binomial coefficient
println(binomial(6, 3))
println(binomial(-6, 3))
println(binomial(-6, -2))
println(binomial(5, 2))

                    
Output:
20
-56
0
10