/
prog.pl
54 lines (38 loc) · 895 Bytes
/
prog.pl
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
#!/usr/bin/perl
# a(n) = beginning of a run of at least n primes when x -> 3*x - 2 is iterated.
# https://oeis.org/A323713
# Terms:
# 2, 3, 3, 5, 61, 1171241, 1197631, 25451791, 25451791, 9560914721, 9560914721, 860964705721, 185133795875771
use 5.014;
use ntheory qw(:all);
my %table;
use 5.014;
use ntheory qw(:all);
{
my $x = 9560914721;
for my $k (1..15) {
say "[$k] $x -> ", is_prime($x);
$x = 3*$x - 2;
}
}
forprimes {
my $k = $_;
my $count = 2;
my $x = 3*$k - 2;
while (is_prime($x)) {
if (not exists $table{$count}) {
$table{$count} = $k;
say "a($count) = $k";
}
$x = 3*$x - 2;
++$count;
}
#if ($count > 11) {
# say "a($count) = $k";
#}
#if ($count == 10) {
# die "Found -- $k";
#}
} 1000000000;
use Data::Dump qw(pp);
pp \%table;