tag:blogger.com,1999:blog-4815481734454081491.post7338493341346158986..comments2023-10-24T02:15:03.269-07:00Comments on Minborg's Java Pot: An O(1) n-factorial Support Class for Java 8Per Minborghttp://www.blogger.com/profile/08526963148025854611noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-4815481734454081491.post-77592922923737583042017-01-12T14:24:41.106-08:002017-01-12T14:24:41.106-08:00Thanks for providing this! I was looking for some...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:<br /><br />public static BigDecimal factorial(int n)<br /> return LongStream.rangeClosed(2, n)<br /> .parallel()<br /> .asDoubleStream()<br /> .mapToObj(BigDecimal::new)<br /> .reduce(BigDecimal::multiply)<br />}<br /><br />I'm not a performance expert, but it seems fairly fast. I'm not sure what the practical application might be for it though...<br />Matthttps://www.blogger.com/profile/03793237100365475875noreply@blogger.com