Reduce allocations and refactoring
This commit is contained in:
parent
3cf341159b
commit
4bac47687b
@ -1,4 +1,4 @@
|
|||||||
using Base:Integer
|
using Base: Integer
|
||||||
#=
|
#=
|
||||||
Created on 25 Jul 2021
|
Created on 25 Jul 2021
|
||||||
|
|
||||||
@ -17,8 +17,11 @@ function Problem15()
|
|||||||
right corner.
|
right corner.
|
||||||
|
|
||||||
How many such routes are there through a 20×20 grid? =#
|
How many such routes are there through a 20×20 grid? =#
|
||||||
n = 20
|
n::Int8 = 20
|
||||||
return Integer(factorial(big(2n)) / (factorial(big(n)) * factorial(big(2n - n))))
|
numerator::BigInt = factorial(big(2n))
|
||||||
|
denominator1::BigInt = big(factorial(n))
|
||||||
|
denominator2::BigInt = big(factorial(2n - n))
|
||||||
|
return BigInt(numerator / (denominator1 * denominator2))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user