// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class PriPub {
    private static long fac(int n) {
        long res = 1;
        for(int i = 1; i <= n; i++) {
            res *= i;
        }
        return res;
    }
    public static int comb1(int n, int p) {
        return (int)(fac(n)/(fac(n-p)*fac(p)));
    }
    public static int comb2(int n, int p) {
        long res = 1;
        for(int i = n; i > n-p; i--) {
            res *= i;
        }
        for(int i = 1; i <= p; i++) {
            res /= i;
        }
        return (int) res;
    }
    public static void main(String[] args) {
        System.out.println(comb1(12, 3));
        System.out.println(comb2(12, 3));
    }
}
