You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
541 B
38 lines
541 B
package net.mightypork.rcalc.operations;
|
|
|
|
|
|
import net.mightypork.rcalc.IEvaluable;
|
|
import net.mightypork.rcalc.numbers.Fraction;
|
|
|
|
|
|
/**
|
|
* Factorial
|
|
*
|
|
* @author Ondrej Hruska
|
|
*/
|
|
public class OperationFactorial extends UnaryOperation {
|
|
|
|
/**
|
|
* Create factorial
|
|
*
|
|
* @param operand operand
|
|
*/
|
|
public OperationFactorial(IEvaluable operand) {
|
|
|
|
super(operand);
|
|
}
|
|
|
|
|
|
@Override
|
|
public Fraction evaluate() {
|
|
|
|
return operand.evaluate().factorial();
|
|
}
|
|
|
|
|
|
@Override
|
|
public String toString() {
|
|
|
|
return "FCT{" + operand + "}";
|
|
}
|
|
}
|
|
|