binomial-coefficients

How would you write this algorithm for large combinations in the most compact way?

The number of combinations of k items which can be retrieved from N items is described by the following formula. N! c = ___________________ (k! * (N - k)!) An example would be how many combinations of 6 Balls can be drawn from a drum of 48 Balls in a lottery draw. Optimize this formula to run with the smallest ...

What is a good way to implement choose notation in Java?

... preferably in Java. Here is what I have: //x choose y public static double choose(int x, int y) { if (y < 0 || y > x) return 0; if (y == 0 || y == x) return 1; double answer = 1; for (int i = x-y+1; i <= x; i++) { answer = answer * i; } for (int j = y; j > 1; j--) { answer = answer / j; } return answer; } I'm wonderin...

Binomial test in Python for very large numbers

I need to do a binomial test in Python that allows calculation for 'n' numbers of the order of 10000. I have implemented a quick binomial_test function using scipy.misc.comb, however, it is pretty much limited around n = 1000, I guess because it reaches the biggest representable number while computing factorials or the combinatorial its...

Double-checked locking for growable array of binomial coefficients

I'm trying to use double-checked locking to maintain an array of binomial coefficients, but I read recently that double-checked locking doesn't work. Efficiency is extremely important so using volatile isn't an option unless it's only inside the conditional statements. I can't see a way to use a static class with a singleton object (th...

Binomial Coefficient using Tail Recursion in LISP

Hello, I'm a Computer Science student starting to learn LISP. I have been said to program a function to find C(n,k) using tail recursion, and I would greatly appreciate your help. I have reached this: (defun combinatorio-recursivo-cola (n k) (cond ((or (< n k) (< k 0)) NIL) ((or (= k 0) (= n k)) 1) (T (* (combinatorio...