Fix EOF
This commit is contained in:
@@ -5,10 +5,9 @@ Created on 21 Jul 2021
|
||||
@email: daviddoji@pm.me
|
||||
|
||||
Solution for Problem 12 of Project Euler
|
||||
https://projecteuler.net/problem=12
|
||||
=#
|
||||
|
||||
https://projecteuler.net/problem=12 =#
|
||||
|
||||
using BenchmarkTools
|
||||
|
||||
function Problem12()
|
||||
#=
|
||||
@@ -32,14 +31,13 @@ function Problem12()
|
||||
We can see that 28 is the first triangle number to have over five divisors.
|
||||
|
||||
What is the value of the first triangle number to have over five hundred
|
||||
divisors?
|
||||
=#
|
||||
divisors? =#
|
||||
|
||||
function num_divisors(n)
|
||||
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)
|
||||
@@ -51,7 +49,7 @@ function Problem12()
|
||||
end
|
||||
|
||||
|
||||
println("Time to evaluate Problem 12:")
|
||||
@time Problem12()
|
||||
println("Time to evaluate Problem $(lpad(12, 3, "0")):")
|
||||
@btime Problem12()
|
||||
println("")
|
||||
println("Result for Problem 12: ", Problem12())
|
||||
println("Result for Problem $(lpad(12, 3, "0")): ", Problem12())
|
||||
|
||||
Reference in New Issue
Block a user