nd4j-common/src/main/java/org/nd4j/linalg/util/Factorial.java
public BigInteger at(int n) {
        while (a.size() <= n) {
            final int lastn = a.size() - 1;
            final BigInteger nextn = BigInteger.valueOf(lastn + 1);
            a.add(a.get(lastn).multiply(nextn));
        }
        return a.get(n);
    }
public BigInteger at(int n) {
        while (a.size() <= n) {
            final int lastn = a.size() - 1;
            final BigInteger nextn = BigInteger.valueOf(lastn + 1);
            a.add(a.get(lastn).multiply(nextn));
        }
        return a.get(n);
    }
Compute the factorial of the non-negative integer.

@param n the argument to the factorial, non-negative.
@return the factorial of n.