Reduce allocations and refactoring

This commit is contained in:
David Doblas Jiménez 2022-10-12 20:46:48 +02:00
parent 3cf341159b
commit 4bac47687b

View File

@ -17,8 +17,11 @@ function Problem15()
right corner.
How many such routes are there through a 20×20 grid? =#
n = 20
return Integer(factorial(big(2n)) / (factorial(big(n)) * factorial(big(2n - n))))
n::Int8 = 20
numerator::BigInt = factorial(big(2n))
denominator1::BigInt = big(factorial(n))
denominator2::BigInt = big(factorial(2n - n))
return BigInt(numerator / (denominator1 * denominator2))
end