function factory( N, K, n ) {
	if (
		isnan( N ) ||
		isnan( K ) ||
		isnan( n ) ||
		!isNonNegativeInteger( N ) ||
		!isNonNegativeInteger( K ) ||
		!isNonNegativeInteger( n ) ||
		N === PINF ||
		K === PINF ||
		K > N ||
		n > N
	) {
		return constantFunction( NaN );
	}
	return quantile;

	/**
	* Evaluates the quantile function for a hypergeometric distribution.
	*
	* @private
	* @param {Probability} p - input value
	* @returns {NonNegativeInteger} evaluated quantile function
	*/
	function quantile( p ) {
		var prob;
		var x;

		if ( isnan( p ) || p < 0.0 || p > 1.0 ) {
			return NaN;
		}
		if ( p === 0.0 ) {
			return max( 0, n + K - N );
		}
		if ( p === 1.0 ) {
			return min( n, K );
		}
		x = max( 0, n + K - N );
		while ( true ) {
			prob = cdf( x, N, K, n );
			if ( prob > p ) {
				break;
			}
			x += 1;
		}
		return x;
	}
}
Returns a function for evaluating the quantile function for a hypergeometric distribution with population size `N`, subpopulation size `K`, and number of draws `n`.

@param {NonNegativeInteger} N - population size
@param {NonNegativeInteger} K - subpopulation size
@param {NonNegativeInteger} n - number of draws
@returns {Function} quantile function

@example
var quantile = factory( 100, 20, 10 );
var y = quantile( 0.2 );
// returns 1

y = quantile( 0.9 );
// returns 4