-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_a16.sf
75 lines (54 loc) · 2.06 KB
/
find_a16.sf
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/ruby
# a(n) is the least prime p such that there exists a prime q with p^2 + n = (n+1)*q^2, or 0 if there is no such p.
# https://oeis.org/A350544
# If it is not 0, then a(16) = A199773(k) where k is the smallest index such that both p = A199773(k) and q = A199772(k) are prime. If such an index exists, a(16) > 10^10000. - Jon E. Schoenfield, Jan 11 2022
# Known terms:
# 7, 5, 0, 11, 7, 13, 5, 0, 41, 23, 17, 10496997797584752004430879, 41, 11, 7
# Integer solution formulas provided by Wolfram|Alpha:
# https://www.wolframalpha.com/input?i=17*x%5E2+-+16+%3D+y%5E2
# Related sequence:
# https://oeis.org/A350550
# 05 May 2022: Searched up to n = 15053. If a(16) exists, then a(16) > 10^27388. This search took 2:49:27.90.
var Q17 = sqrtQ(17)
for n in (15053 .. 1e9) {
var x = -(-17*((33 - 8*Q17)**n) + Q17*(33 - 8*Q17)**n - 17*(33 + 8*Q17)**n - Q17*(33 + 8*Q17)**n)/34
var y = -(-((33 - 8*Q17)**n) + Q17*(33 - 8*Q17)**n - (33 + 8*Q17)**n - Q17*(33 + 8*Q17)**n)/2
assert(x.a.is_int)
assert(y.a.is_int)
if (17*x.a**2 - 16 == y.a**2) {
#say x
}
else {
say 'error'
}
say "Testing: n = #{n} (value has #{y.a.len} digits)"
if (all_prime(x.a, y.a)) {
die "[1] Found: a(16) = #{y.a}"
}
x = (17 * (33 - 8*Q17)**n + Q17*(33 - 8*Q17)**n + 17*(33 + 8*Q17)**n - Q17*(33 + 8*Q17)**n)/34
y = -((33 - 8*Q17)**n + Q17*(33 - 8*Q17)**n + (33 + 8*Q17)**n - Q17*(33 + 8*Q17)**n)/2
assert(x.a.is_int)
assert(y.a.is_int)
if (17*x.a**2 - 16 == y.a**2) {
#say x
}
else {
say 'error'
}
if (all_prime(x.a, y.a)) {
die "[2] Found: a(16) = #{y.a}"
}
x = 2*(17*(33 - 8*Q17)**n + 4*Q17*(33 - 8*Q17)**n + 17*(33 + 8*Q17)**n - 4*Q17*(33 + 8*Q17)**n)/17
y = -2*(4*(33 - 8*Q17)**n + Q17*(33 - 8*Q17)**n + 4*(33 + 8*Q17)**n - Q17*(33 + 8*Q17)**n)
assert(x.a.is_int)
assert(y.a.is_int)
if (17*x.a**2 - 16 == y.a**2) {
#say x
}
else {
say 'error'
}
if (all_prime(x.a, y.a)) {
die "[3] Found: a(16) = #{y.a}"
}
}