-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathgoldbach_conjecture_increasing_primes.pl
More file actions
executable file
·66 lines (53 loc) · 1.15 KB
/
goldbach_conjecture_increasing_primes.pl
File metadata and controls
executable file
·66 lines (53 loc) · 1.15 KB
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
#!/usr/bin/perl
# Daniel "Trizen" Șuteu
# License: GPLv3
# Date: 16 September 2016
# Website: https://github.com/trizen
# The smallest prime p such that (2n - p) is also a prime number,
# and the prime p is the largest prime seen so far.
# Analyzing this sequence, may give us an insight into the Golbach's conjecture.
use strict;
use warnings;
use ntheory qw(primes is_prime);
my $limit = 1000000;
my @primes = @{primes($limit)};
my $max = 0;
OUTER: for (my $i = 4 ; $i <= $limit ; $i += 2) {
foreach my $p (@primes) {
if (is_prime($i - $p)) {
if ($p > $max) {
$max = $p;
printf("%7s %7s\n", $i, $p);
}
next OUTER;
}
}
}
__END__
Output for 2n <= 10^7:
n p
----- -----
4 2
6 3
12 5
30 7
98 19
220 23
308 31
556 47
992 73
2642 103
5372 139
7426 173
43532 211
54244 233
63274 293
113672 313
128168 331
194428 359
194470 383
413572 389
503222 523
1077422 601
3526958 727
3807404 751