Refactoring for memory allocation improvement
This commit is contained in:
parent
7e6e92b13e
commit
da0f1ba9a6
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user