-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path043.jl
39 lines (35 loc) · 940 Bytes
/
043.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# https://projecteuler.net/problem=43
using Combinatorics
function prop(n::Vector{Int})
s = join(string.(n))
d = Vector{String}(10)
for i in 1:10
d[i] = string(s[i])
end
ret = false
if parse(Int, d[2]*d[3]*d[4]) % 2 == 0
if parse(Int, d[3]*d[4]*d[5]) % 3 == 0
if parse(Int, d[4]*d[5]*d[6]) % 5 == 0
if parse(Int, d[5]*d[6]*d[7]) % 7 == 0
if parse(Int, d[6]*d[7]*d[8]) % 11 == 0
if parse(Int, d[7]*d[8]*d[9]) % 13 == 0
if parse(Int, d[8]*d[9]*d[10]) % 17 == 0
ret = true
end
end
end
end
end
end
end
return ret
end
pr = permutations(0:9, 10)
s = 0
for p in pr
s =
if prop(p)
s += parse(Int, join(string.(p)))
end
end
s |> println