diff --git a/src/Julia/Problem012.jl b/src/Julia/Problem012.jl index 6b9e304..17054df 100644 --- a/src/Julia/Problem012.jl +++ b/src/Julia/Problem012.jl @@ -36,18 +36,10 @@ function Problem12() =# function num_divisors(n) - res = floor(Int, sqrt(n)) - divs = Int[] - for i = 1:res - if n % i == 0 - append!(divs, i) - end - end - if res^2 == n - pop!(divs) - end - return 2 * length(divs) + r = isqrt(n) + 2 * count(n % i == 0 for i in 1:r) - (r^2 == n) end + triangle = 0 for i in Iterators.countfrom(1)