public static BigDecimal factorial(final Value v) {
        Value.assertType(v, vv -> vv.isLongBetween(1, 50), "integer in range 1-50");
        final int facValue = (int) v.getAsLong();
        BigDecimal result = BigDecimal.ONE;
        for (int i = 2; i <= facValue; i++) {
            result = result.multiply(BigDecimal.valueOf(i));
        }
        return result;
    }
Holds implementations for functions in Formula
main/src/main/java/cgeo/geocaching/utils/formulas/FormulaUtils.java