Improve performance

This commit is contained in:
David Doblas Jiménez 2021-07-22 10:41:14 +02:00
parent 330116f70c
commit 45338f7fdd

View File

@ -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