MonteCarlo.cpp
unsigned
ML_RandomLessThanN(unsigned nModulus)
{
    unsigned nRemainder, n;

    nRemainder = 0xFFFFFFFF % nModulus;
    do {
        n = ML_RandomUnsigned();
    } while (n <= nRemainder);
    return n % nModulus;
}
//
//  Uniform distribution from 0 to N-1
//

Uniform distribution from 0 to N-1
Uniform distribution from 0 to N - 1
unsigned
ML_RandomLessThanN(unsigned nModulus)
{
    unsigned nRemainder, n;
    nRemainder = 0xFFFFFFFF % nModulus;
    do {
        n = ML_RandomUnsigned();
    } while (n <= nRemainder);
    return n % nModulus;
}
unsigned ML_RandomLessThanN ( unsigned nModulus ) { unsigned nRemainder , n ; nRemainder = 0xFFFFFFFF % nModulus ; do { n = ML_RandomUnsigned ( ) ; } while ( n <= nRemainder ) ; return n % nModulus ; }
Uniform distribution from 0 to N-1
Uniform distribution from 0 to N - 1