Added functions to calculate factorial and density of binomial distribution