package test;
import java.math.BigDecimal;
import java.math.BigInteger;
public class BigRoot {
public static BigDecimal bigRoot(BigDecimal number, int n, int scale, int roundingMode) {
boolean negate = false;
if (n < 0)
throw new ArithmeticException();
if (number.compareTo(BigDecimal.ZERO) < 0) {
if (n % 2 == 0)
throw new ArithmeticException();
else {
number = number.negate();
negate = true;
}
}
BigDecimal root;
if (n == 0)
root = BigDecimal.ONE;
else if (n == 1)
root = number;
else {
final BigInteger N = BigInteger.valueOf(n);
final BigInteger N2 = BigInteger.TEN.pow(n);
final BigInteger N3 = BigInteger.TEN.pow(n - 1);
final BigI