-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog.pl
46 lines (36 loc) · 1 KB
/
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
# a(n) is the smallest n-gonal number with exactly n distinct prime factors.
# https://oeis.org/A358862
# Known terms:
# 66, 44100, 11310, 103740, 3333330, 185040240, 15529888374, 626141842326, 21647593547580
use 5.020;
use ntheory qw(:all);
use experimental qw(signatures);
# PARI/GP program:
# a(n) = if(n<3, return()); for(k=1, oo, my(t=(k*(n*k - n - 2*k + 4))\2); if(omega(t) == n, return(t)));
sub a($n) {
for(my $k = 1; ; ++$k) {
#my $t = divint(mulint($k, ($n*$k - $n - 2*$k + 4)), 2);
my $t = rshiftint(mulint($k, ($n*$k - $n - 2*$k + 4)), 1);
#my $t = ($k * ($n*$k - $n - 2*$k + 4))>>1;
#if (prime_omega($t) == $n) {
if (is_omega_prime($n, $t)) {
return $t;
}
}
}
foreach my $n (3..100) {
say "a($n) = ", a($n);
}
__END__
a(3) = 66
a(4) = 44100
a(5) = 11310
a(6) = 103740
a(7) = 3333330
a(8) = 185040240
a(9) = 15529888374
a(10) = 626141842326
a(11) = 21647593547580
a(12) = 351877410344460
a(13) = 82634328555218440