mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-18 16:25:27 +02:00
parent
5a7fd41cf5
commit
ebb5fc52e0
@ -93,6 +93,8 @@ internal fun BigDecimal.factorial(): BigDecimal {
|
||||
if (this < BigDecimal.ZERO) throw ExpressionException.FactorialCalculation()
|
||||
if (this > maxFactorial) throw ExpressionException.TooBig()
|
||||
|
||||
if (this.compareTo(BigDecimal.ZERO) == 0) return BigDecimal.ONE
|
||||
|
||||
var expr = this
|
||||
for (i in 1 until this.toInt()) {
|
||||
expr *= BigDecimal(i)
|
||||
|
@ -108,4 +108,7 @@ class ExpressionSimpleTest {
|
||||
|
||||
@Test
|
||||
fun expression28() = assertExpr("e", "2.7182818285")
|
||||
|
||||
@Test
|
||||
fun expression29() = assertExpr("0!", "1")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user