Comments on: An O(1) n-factorial Support Class for Java 8 https://speedment.com/an-o1-n-factorial-support-class-for-java-8/ Build Fast Java Applications for the Fastest Business Performance Fri, 01 May 2020 05:21:37 +0000 hourly 1 https://wordpress.org/?v=5.1.1 By: Matt https://speedment.com/an-o1-n-factorial-support-class-for-java-8/#comment-96 Thu, 12 Jan 2017 22:24:41 +0000 https://speedment.com/an-o1-n-factorial-support-class-for-java-8/#comment-96 Thanks for providing this! I was looking for something that would take me beyond the !20 threshold, and using your example, I came up with this:

public static BigDecimal factorial(int n)
return LongStream.rangeClosed(2, n)
.parallel()
.asDoubleStream()
.mapToObj(BigDecimal::new)
.reduce(BigDecimal::multiply)
}

I'm not a performance expert, but it seems fairly fast. I'm not sure what the practical application might be for it though…

]]>