34 lines
862 B
Julia
34 lines
862 B
Julia
#=
|
|
Created on 26 Sep 2021
|
|
|
|
@author: David Doblas Jiménez
|
|
@email: daviddoji@pm.me
|
|
|
|
Solution for Problem 52 of Project Euler
|
|
https://projecteuler.net/problem=52
|
|
=#
|
|
|
|
using BenchmarkTools
|
|
|
|
function Problem52()
|
|
#=
|
|
It can be seen that the number, 125874, and its double, 251748,
|
|
contain exactly the same digits, but in a different order.
|
|
|
|
Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x,
|
|
and 6x, contain the same digits.
|
|
=#
|
|
|
|
for number in 123456:1_000_000
|
|
if sort(digits(number)) == sort(digits(2*number)) == sort(digits(3*number)) == sort(digits(4*number)) == sort(digits(5*number)) == sort(digits(6*number))
|
|
return number
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
println("Time to evaluate Problem $(lpad(52, 3, "0")):")
|
|
@btime Problem52()
|
|
println("")
|
|
println("Result for Problem $(lpad(52, 3, "0")): ", Problem52())
|