-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprog.pl
46 lines (33 loc) · 761 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
#!/usr/bin/perl
# Smallest a(n) > n such that concatenation of numbers from n to a(n) is a prime.
# https://oeis.org/A084559
use 5.014;
use strict;
use warnings;
use Math::Prime::Util::GMP qw(is_prob_prime factor trial_factor);
sub a {
my ($n) = @_;
my $t = $n;
for(my $k = $n+1; ;++$k) {
$t .= $k;
#say "Testing: $k";
#say "Factoring: $t";
my @f = trial_factor($t, 1e6);
if (@f > 1) {
}
else {
say "[$k] Candidate: $t";
sleep 1;
}
#say join' ', trial_factor($t);
#say '';
#sleep 1;
if (is_prob_prime($t)) {
return $k;
}
}
}
say a(10);
#foreach my $n(2..100) {
# say "a($n) = ", a($n);
#}