-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathp33.jl
48 lines (43 loc) · 1.29 KB
/
p33.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
40
41
42
43
44
45
46
47
48
# Apologies to Julia aficionados! This code is an ugly embarrassment that
# doesn't deserve to be associated with a beautiful language like Julia.
p = 1
for a = 0:9
for b = 0:9
for s = 0:9
# Try all possible arrangements
# sa/sb
if s != 0 && b != 0
r1 = ((10 * s) + a) // ((10 * s) + b)
r2 = a // b
if r1 < 1 && r1 == r2
global p *= r2
end
end
# as/sb
if s != 0 && a != 0 && b != 0
r1 = ((10 * a) + s) // ((10 * s) + b)
r2 = a // b
if r1 < 1 && r1 == r2
global p *= r2
end
end
# as/bs
if a != 0 && b != 0 && s != 0
r1 = ((10 * a) + s) // ((10 * b) + s)
r2 = a // b
if r1 < 1 && r1 == r2
global p *= r2
end
end
# sa/bs
if s != 0 && b != 0
r1 = ((10 * s) + a) // ((10 * b) + s)
r2 = a // b
if r1 < 1 && r1 == r2
global p *= r2
end
end
end
end
end
println(denominator(p))