Fix bug in CalculatorService incorrectly capturing the 'operand' of the mathematical function.

This commit is contained in:
John Blum
2019-08-01 14:01:31 -07:00
parent ea7170f8dc
commit 532599aa2a

View File

@@ -57,13 +57,14 @@ public class CalculatorService extends AbstractCacheableService {
return ResultHolder.of(number, Operator.FACTORIAL, number == 2 ? 2 : 1);
}
int operand = number;
int result = number;
while (--number > 1) {
result *= number;
}
return ResultHolder.of(number, Operator.FACTORIAL, result);
return ResultHolder.of(operand, Operator.FACTORIAL, result);
}
@Cacheable(value = "SquareRoots", keyGenerator = "resultKeyGenerator")