From 4bac47687b84a4221f1cead31b95481961450e3c Mon Sep 17 00:00:00 2001 From: daviddoji Date: Wed, 12 Oct 2022 20:46:48 +0200 Subject: [PATCH] Reduce allocations and refactoring --- src/Julia/Problems001-050/Problem015.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Julia/Problems001-050/Problem015.jl b/src/Julia/Problems001-050/Problem015.jl index 79ff957..8c13d83 100644 --- a/src/Julia/Problems001-050/Problem015.jl +++ b/src/Julia/Problems001-050/Problem015.jl @@ -1,4 +1,4 @@ -using Base:Integer +using Base: Integer #= Created on 25 Jul 2021 @@ -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