-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprog.pl
86 lines (71 loc) · 2.43 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/perl
# a(1)=2048. For n>1, a(n) is the LCM of a(n-1) and A140635(a(n-1)).
# https://oeis.org/A351162
# Previously known terms:
# 2048, 30720, 645120, 7096320, 92252160, 1383782400, 23524300800
# This sequence converges at n = 35. I.e.: a(n) = a(35) for all n >= 36. - Daniel Suteu, Mar 15 2022
use 5.020;
use warnings;
use experimental qw(signatures);
use ntheory qw(nth_prime divisor_sum);
use Math::AnyNum qw(:overload lcm);
sub smallest_number_with_n_divisors ($threshold, $least_solution = Inf, $k = 1, $max_a = Inf, $solutions = 1, $n = 1) {
if ($solutions == $threshold) {
return $n;
}
if ($solutions > $threshold) {
return $least_solution;
}
my $p = nth_prime($k);
for (my $a = 1 ; $a <= $max_a ; ++$a) {
$n *= $p;
last if ($n > $least_solution);
$least_solution = __SUB__->($threshold, $least_solution, $k + 1, $a, $solutions * ($a + 1), $n);
}
return $least_solution;
}
my $u = 2048;
say "a(1) = $u";
foreach my $n (2..100) {
my $sigma0 = divisor_sum($u, 0);
my $v = lcm($u, smallest_number_with_n_divisors($sigma0));
say "a($n) = $v";
$u = $v;
}
__END__
a(1) = 2048
a(2) = 30720
a(3) = 645120
a(4) = 7096320
a(5) = 92252160
a(6) = 1383782400
a(7) = 23524300800
a(8) = 446961715200
a(9) = 10280119449600
a(10) = 71960836147200
a(11) = 2086864248268800
a(12) = 64692791696332800
a(13) = 582235125266995200
a(14) = 21542699634878822400
a(15) = 883250685030031718400
a(16) = 37979779456291363891200
a(17) = 189898897281456819456000
a(18) = 8925248172228470514432000
a(19) = 473038153128108937264896000
a(20) = 5203419684409198309913856000
a(21) = 307001761380142700284917504000
a(22) = 18727107444188704717379967744000
a(23) = 1254716198760643216064457838848000
a(24) = 89084850112005668340576506558208000
a(25) = 1158103051456073688427494585256704000
a(26) = 84541522756293379255207104723739392000
a(27) = 6678780297747176961161361273175411968000
a(28) = 554338764713015687776392985673559193344000
a(29) = 49336150059458396212098975724946768207616000
a(30) = 345353050416208773484692830074627377453312000
a(31) = 33499245890372251028015204517238855612971264000
a(32) = 3383423834927597353829535656241124416910097664000
a(33) = 348492654997542527444442172592835814941740059392000
a(34) = 37288714084737050436555312467433432198766186354944000
a(35) = 4064469835236338497584529058950244109665514312688896000
a(36) = 4064469835236338497584529058950244109665514312688896000