JSFiddle - React, Tailwind, and code Playground

by sutherland

JavaScript

var totalCards = 162;
var startCards = 30;
var players = 3;
var playerStack = 24;

// This is the auto stuff.

function sFact(num)
{
    var rval=1;
    for (var i = 2; i <= num; i++)
        rval = rval * i;
    return rval;
}

var totalPlayerStack = players * playerStack;

var probability = 1;
for ( var i=0; i<startCards; i++ ) {
    result = ( startCards - i ) / ( totalCards - i )
    probability = probability * result;
}

combinations = sFact( totalPlayerStack ) / ( sFact( startCards ) * sFact( totalPlayerStack - startCards ) );
probability = probability * combinations;
console.log( probability );