Calculator of combinations without repetition
One trick is to keep the partial products in small, \${n}\choose{k}\$ so they don't overflow. 

I iteratively multiply \$n/(n-k)\$ by \$(n-1)/(n-k-1)\$, cache the result in an accumulator, multiply that by \$(n-2)/(n-k-2)\$ and so forth.

#include &lt;iostream&gt;

template &lt;class T&gt;
T choose(T n, T k)
{
    T accum = 1;
    T m = n;
    for (T i = 1; i &lt;= m - k; i++)
    {
        accum = accum * n / (n - k);
        n--;
    }
    return accum;
}

int main()
{
    std::cout &lt;&lt; std::fixed;
    long double n = 50, k = 25;
    std::cout &lt;&lt; "\nLDBL_MAX" &lt;&lt; LDBL_MAX;
    long double result = choose(n, k);
    std::cout &lt;&lt; "\nC(" &lt;&lt; n &lt;&lt; "," &lt;&lt; k &lt;&lt; ") = " &lt;&lt; result;
    std::cin.clear();
    std::cin.get();
    return 0;
}