-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog.sf
83 lines (71 loc) · 3 KB
/
prog.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
76
77
78
79
80
81
82
83
#!/usr/bin/ruby
# a(n) is the least prime P such that P^(2*prime(n))-P^prime(n)-1 is prime with prime(n) the n-th prime.
# https://oeis.org/A131580
# First 100 terms:
# 2, 3, 2, 3, 163, 19, 151, 263, 131, 3041, 311, 401, 2029, 1163, 2309, 157, 541, 61, 739, 563, 1097, 4813, 1801, 1399, 709, 317, 14563, 863, 5479, 337, 2351, 9533, 4931, 401, 1117, 14639, 17791, 1409, 571, 5171, 16633, 7001, 2129, 10891, 31151, 22709, 6079, 883, 20113, 61, 311, 24023, 2671, 4643, 1031, 2399, 22621, 6763, 101, 3299, 41479, 2699, 1523, 8521, 9239, 1289, 2521, 36677, 34981, 22369, 58831, 1303, 15991, 42667, 53189, 6421, 5279, 10079, 35107, 7877, 108289, 9851, 2179, 7499, 11831, 16091, 1597, 26987, 1601, 38543, 15971, 40933, 2293, 55439, 23, 20161, 71809, 431, 3, 31177
func a(n) {
var pn = prime(n)
for (var p = 2; true; p.next_prime!) {
if (p**(2*pn) - p**pn - 1 -> is_prob_prime) {
return p
}
}
}
say "First 10 terms: "
say 10.of { a(_+1) }
say "\nTrying to find more terms, starting with a(101):"
for n in (101..200) { # find more terms
print(a(n), ", ")
}
say ''
var arr = [
2, 3, 2, 3, 163, 19, 151, 263, 131, 3041, 311, 401, 2029, 1163, 2309, 157, 541, 61, 739, 563, 1097, 4813, 1801, 1399, 709, 317, 14563, 863, 5479, 337, 2351, 9533, 4931, 401, 1117, 14639, 17791, 1409, 571, 5171, 16633, 7001, 2129, 10891, 31151, 22709, 6079, 883, 20113, 61, 311, 24023, 2671, 4643, 1031, 2399, 22621, 6763, 101, 3299, 41479, 2699, 1523, 8521, 9239, 1289, 2521, 36677, 34981, 22369, 58831, 1303, 15991, 42667, 53189, 6421, 5279, 10079, 35107, 7877, 108289, 9851, 2179, 7499, 11831, 16091, 1597, 26987, 1601, 38543, 15971, 40933, 2293, 55439, 23, 20161, 71809, 431, 3, 31177
]
for k,p in (arr.kv) {
var pn = prime(k+1)
var t = (p**(2*pn) - p**pn - 1)
if (t.len > 2000) {
say "#{p}^(2*#{pn}) - #{p}^#{pn} - 1"
}
}
__END__
# Primes with more than 2000 digits:
24023^(2*239) - 24023^239 - 1
22621^(2*269) - 22621^269 - 1
6763^(2*271) - 6763^271 - 1
41479^(2*283) - 41479^283 - 1
2699^(2*293) - 2699^293 - 1
8521^(2*311) - 8521^311 - 1
9239^(2*313) - 9239^313 - 1
2521^(2*331) - 2521^331 - 1
36677^(2*337) - 36677^337 - 1
34981^(2*347) - 34981^347 - 1
22369^(2*349) - 22369^349 - 1
58831^(2*353) - 58831^353 - 1
1303^(2*359) - 1303^359 - 1
15991^(2*367) - 15991^367 - 1
42667^(2*373) - 42667^373 - 1
53189^(2*379) - 53189^379 - 1
6421^(2*383) - 6421^383 - 1
5279^(2*389) - 5279^389 - 1
10079^(2*397) - 10079^397 - 1
35107^(2*401) - 35107^401 - 1
7877^(2*409) - 7877^409 - 1
108289^(2*419) - 108289^419 - 1
9851^(2*421) - 9851^421 - 1
2179^(2*431) - 2179^431 - 1
7499^(2*433) - 7499^433 - 1
11831^(2*439) - 11831^439 - 1
16091^(2*443) - 16091^443 - 1
1597^(2*449) - 1597^449 - 1
26987^(2*457) - 26987^457 - 1
1601^(2*461) - 1601^461 - 1
38543^(2*463) - 38543^463 - 1
15971^(2*467) - 15971^467 - 1
40933^(2*479) - 40933^479 - 1
2293^(2*487) - 2293^487 - 1
55439^(2*491) - 55439^491 - 1
20161^(2*503) - 20161^503 - 1
71809^(2*509) - 71809^509 - 1
431^(2*521) - 431^521 - 1
31177^(2*541) - 31177^541 - 1