-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog.pl
53 lines (40 loc) · 1007 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
#!/usr/bin/perl
# a(n) is the smallest number k such that factorizations of n consecutive integers starting at k have the same excess of number of primes counted with multiplicity over number of primes counted without multiplicity (A046660).
# https://oeis.org/draft/A323253
#~ a(1) = 4
#~ a(2) = 6
#~ a(3) = 21
#~ a(4) = 844
#~ a(5) = 74849
#~ a(6) = 671346
#~ a(7) = 8870025
# See also:
# https://oeis.org/A072072
use 5.020;
use warnings;
use ntheory qw(:all);
use experimental qw(signatures);
sub excess ($n) {
scalar(factor($n)) - scalar(factor_exp($n));
}
sub score ($n) {
my $t = excess($n);
foreach my $k(1..100) {
if (excess($k + $n) != $t) {
return $k;
}
}
}
my $n = 1;
#my $upto = 30199064929748;
#my $upto = 80566783622;
#my $upto = 300000000000000 + 4*1e6;
my $from = 30199064929748 + 2*1e7;
forcomposites {
while (score($_) >= $n) {
say "a($n) = ", $_;
++$n;
}
} $from, $from+1e7;
__END__
a(7) = 30199059114825