Fix EOF
This commit is contained in:
@@ -5,24 +5,23 @@ Created on 18 Sep 2021
|
||||
@email: daviddoji@pm.me
|
||||
|
||||
Solution for Problem 47 of Project Euler
|
||||
https://projecteuler.net/problem=47
|
||||
=#
|
||||
https://projecteuler.net/problem=47 =#
|
||||
|
||||
using BenchmarkTools
|
||||
|
||||
function factor(n)
|
||||
ans = []
|
||||
d = 2
|
||||
while d*d <= n
|
||||
while d * d <= n
|
||||
if n % d == 0
|
||||
push!(ans,d)
|
||||
push!(ans, d)
|
||||
n = n ÷ d
|
||||
else
|
||||
d += 1
|
||||
end
|
||||
end
|
||||
if n > 1
|
||||
push!(ans,n)
|
||||
push!(ans, n)
|
||||
end
|
||||
return ans
|
||||
end
|
||||
@@ -41,15 +40,14 @@ function Problem47()
|
||||
646 = 2 × 17 × 19.
|
||||
|
||||
Find the first four consecutive integers to have four distinct prime factors each.
|
||||
What is the first of these numbers?
|
||||
=#
|
||||
What is the first of these numbers? =#
|
||||
ans = []
|
||||
|
||||
for number in 1:1_000_000
|
||||
if length(ans) == 4
|
||||
break
|
||||
elseif length(Set(factor(number))) == 4
|
||||
push!(ans,number)
|
||||
push!(ans, number)
|
||||
else
|
||||
ans = []
|
||||
end
|
||||
@@ -59,7 +57,7 @@ function Problem47()
|
||||
end
|
||||
|
||||
|
||||
println("Time to evaluate Problem 47:")
|
||||
println("Time to evaluate Problem $(lpad(47, 3, "0")):")
|
||||
@btime Problem47()
|
||||
println("")
|
||||
println("Result for Problem 47: ", Problem47())
|
||||
println("Result for Problem $(lpad(47, 3, "0")): ", Problem47())
|
||||
|
||||
Reference in New Issue
Block a user