code: public static BigDecimal bernoulli(int n, MathContext mathContext) {
  		if (n < 0) {
  			throw new ArithmeticException("Illegal bernoulli(n) for n < 0: n = " + n);
  		}
  		
  		BigRational b = BigRational.bernoulli(n);
  		return b.toBigDecimal(mathContext);
  	}
docs: Calculates the Bernoulli number for the specified index.
  
  <p>This function calculates the <strong>first Bernoulli numbers</strong> and therefore <code>bernoulli(1)</code> returns -0.5</p>
  <p>Note that <code>bernoulli(x)</code> for all odd x &gt; 1 returns 0</p>
  <p>See: <a href="https://en.wikipedia.org/wiki/Bernoulli_number">Wikipedia: Bernoulli number</a></p>
  
  @param n the index of the Bernoulli number to be calculated (starting at 0)
  @param mathContext the {@link MathContext} used for the result
  @return the Bernoulli number for the specified index
  @throws ArithmeticException if x &lt; 0
  @throws ArithmeticException if the result is inexact but the
  rounding mode is {@code UNNECESSARY} or
  {@code mc.precision == 0} and the quotient has a
  non-terminating decimal expansion.