Solution to problem 52 in Julia
This commit is contained in:
parent
086ee02a6b
commit
a91d499adc
33
src/Julia/Problem052.jl
Normal file
33
src/Julia/Problem052.jl
Normal file
@ -0,0 +1,33 @@
|
||||
#=
|
||||
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 52:")
|
||||
@btime Problem52()
|
||||
println("")
|
||||
println("Result for Problem 52: ", Problem52())
|
Loading…
x
Reference in New Issue
Block a user