From 45338f7fdd5aa38ee46fb2fad1f4edae7d0f343e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Doblas=20Jim=C3=A9nez?= Date: Thu, 22 Jul 2021 10:41:14 +0200 Subject: [PATCH] Improve performance --- src/Julia/Problem012.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Julia/Problem012.jl b/src/Julia/Problem012.jl index ceaee11..497cb41 100644 --- a/src/Julia/Problem012.jl +++ b/src/Julia/Problem012.jl @@ -36,17 +36,17 @@ function Problem12() =# function num_divisors(n) - res = floor(sqrt(n)) + res = floor(Int, sqrt(n)) divs = [] - for i in 1:res - if n%i == 0 - append!(divs,i) + for i = 1:res + if n % i == 0 + append!(divs, i) end end if res^2 == n pop!(divs) end - return 2*length(divs) + return 2 * length(divs) end triangle = 0