During my last statistics exam, I was looking to calculate the value of nCr. But unfortunately, my calculator didn't have the functionality to calculate the value of nCr so i decided to build a combination calculator of my own.

I was quite sure to make it super simple, That's why I have used only the pure javascript or the vanilla javascript, so here no jquery library been used in this simple tool.

nCr or Combination Calculation

means   if you are given “n” number different items and you have to chose “r” number of items from it, then nCr gives the total number of ways possible. can be written as: n! / r! * (n-r)!

Function Description

function factorial(n) {
return (n != 1) ? n * factorial(n - 1) : 1;
};

function combination(n, r) {
return (n == r) ? 1 : factorial(n) / (factorial(r) * factorial(n - r));
};

The factorial() function finds the factorial of a given number and the combination() function return the value of n! / r! * (n-r)! .

I'll be glad to know if you get any help out of it.

Thanks .