public final class FactorialDouble extends Object
Modifier and Type | Method and Description |
---|---|
static FactorialDouble |
create()
Creates an instance with no precomputed values.
|
double |
value(int n)
Computes the factorial of
n . |
FactorialDouble |
withCache(int cacheSize)
Creates an instance with the specified cache size.
|
public static FactorialDouble create()
public FactorialDouble withCache(int cacheSize)
cacheSize
- Number of precomputed values of the function.cacheSize
values have been
precomputed.IllegalArgumentException
- if cacheSize < 0
.public double value(int n)
n
.
The result should be small enough to fit into a double
: The
largest n
for which n!
does not exceed
Double.MAX_VALUE
is 170. Double.POSITIVE_INFINITY
is
returned for n > 170
.n
- Argument.n!
IllegalArgumentException
- if n < 0
.Copyright © 2017–2020 The Apache Software Foundation. All rights reserved.