/** {@inheritDoc} */ @Override public IExpr dec() { return add(F.CN1); }
/** {@inheritDoc} */ @Override public IExpr inc() { return add(F.C1); }
@Override public IInteger subtract(final IInteger that) { return add(that.negate()); }
@Override public IExpr plus(final IExpr that) { if (that instanceof IntegerSym) { return this.add((IntegerSym) that); } if (isZero()) { return that; } if (that instanceof FractionSym) { return FractionSym.valueOf(fInteger).add((FractionSym) that); } return super.plus(that); }
public ISignedNumber minus(ISignedNumber that) { if (that instanceof IntegerSym) { return this.add((IntegerSym) that.negate()); } if (isZero()) { return that.negate(); } if (that instanceof FractionSym) { return FractionSym.valueOf(fInteger).minus(that); } return Num.valueOf(fInteger.doubleValue() - that.doubleValue()); }
} else { p = p.add(IntegerSym.valueOf(2));
/** * Returns the nth-root of this integer. * * @return <code>k<code> such as <code>k^n <= this < (k + 1)^n</code> * @throws ArithmeticException * if this integer is negative and n is even. */ public IInteger nthRoot(int n) throws ArithmeticException { if (sign() == 0) { return IntegerSym.valueOf(0); } else if (sign() < 0) { if (n % 2 == 0) { // even exponent n throw new ArithmeticException(); } else { // odd exponent n return (IntegerSym) ((IntegerSym) negate()).nthRoot(n).negate(); } } else { IntegerSym result; IntegerSym temp = this; do { result = temp; temp = divideAndRemainder(temp.pow(n - 1))[0].add(temp.multiply(IntegerSym.valueOf(n - 1))).divideAndRemainder( IntegerSym.valueOf(n))[0]; } while (temp.compareTo(result) < 0); return result; } }
resultArray[k++] = m; m = m.add(IntegerSym.valueOf(1));
return F.Times(factor, F.Power(rat.numerator(), F.C1.add((IRational) exponent2)));