-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog.pl
49 lines (37 loc) · 850 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
#!/usr/bin/perl
# https://oeis.org/draft/A306978
use 5.020;
use warnings;
use experimental qw(signatures);
sub f ($n) {
my $count = 0;
my $cons = 0;
while ($n != 1) {
++$count;
if ($n % 3 == 0) {
$n = int($n/3);
$cons = 0;
}
else {
if ($cons) {
return -1;
}
$n = int($n * sqrt(3));
$cons = 1;
}
}
$count;
}
foreach my $k(77676682, 134539960, 402368674, 696922987, 1207106023, 2090768962, 3632578906, 6291811228, 10897736719, 18875433685) {
say "$k -> ", f($k);
}
# 6291811228 -- 55
# 10897736719 -- 57
# 18875433685 -- 59
my $record = 59;
foreach my $k(18875433685 * 1.732 ..1e11) {
if (f($k) > $record) {
$record = f($k);
say "New record: $record with $k";
}
}