-
Notifications
You must be signed in to change notification settings - Fork 0
/
e46.ju
56 lines (51 loc) · 904 Bytes
/
e46.ju
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
49
50
51
52
53
54
55
56
function isPrime(x)
if x < 2 || x % 2 == 0
return x == 2
end
i = 3
while i * i <= x
if x % i == 0
return false
end
i += 1
end
return true
end
primes = [2]
for i = 3:10000
if isPrime(i)
primes = [primes..., i]
end
end
squares = [0]
for i = 1:1000
squares = [squares..., i * i]
end
x = 7
while true
gotans = false
for p in primes
done = false
if p > x
println(x)
gotans = true
break
end
for s in squares
if x == p + 2*s
done = true
break
end
if p + 2*s > x
break
end
end
if done
break
end
end
if gotans
break
end
x += 2
end