-
Notifications
You must be signed in to change notification settings - Fork 0
/
smooth_search.pl
123 lines (84 loc) · 2.17 KB
/
smooth_search.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/perl
# Unitary harmonic numbers (A006086) that are not unitary arithmetic numbers (A103826).
# https://oeis.org/A353038
# Known terms:
# 90, 40682250, 81364500, 105773850, 423095400, 1798155450, 14385243600
# No other terms are known.
use 5.020;
use warnings;
use experimental qw(signatures);
use Math::GMPz;
use ntheory qw(:all);
sub check_valuation ($n, $p) {
if ($p == 2) {
return valuation($n, $p) < 7;
}
if ($p == 3) {
return valuation($n, $p) < 7;
}
if ($p == 5) {
return valuation($n, $p) < 6;
}
if ($p == 7) {
return valuation($n, $p) < 5;
}
#~ if ($p == 11) {
#~ return valuation($n, $p) < 2;
#~ }
if ($p == 13) {
return valuation($n, $p) < 2;
}
if ($p == 17) {
return valuation($n, $p) < 2;
}
if ($p == 41) {
return valuation($n, $p) < 2;
}
($n % $p) != 0;
}
sub smooth_numbers ($limit, $primes) {
my @h = (Math::GMPz->new(1));
foreach my $p (@$primes) {
say "Prime: $p";
foreach my $n (@h) {
if ($n * $p <= $limit and check_valuation($n, $p)) {
push @h, $n * $p;
}
}
}
return \@h;
}
#use Math::Sidef qw(usigma usigma0);
sub isok ($n) {
#is_power(Math::GMPz->new(divisor_sum($n)) * euler_phi($n));
# is(n)=my(f=factor(n)); prod(i=1, #f~, f[i, 1]^f[i, 2]+1)%2^#f~==0
my @f = factor_exp($n);
my $usigma = vecprod(map { powint($_->[0], $_->[1]) + 1 } @f);
my $usigma0 = powint(2, scalar(@f));
modint($usigma, $usigma0) == 0
and return;
modint(mulint($n, $usigma0), $usigma) == 0;
#(usigma0($n)*$n) % usigma($n) == 0;
}
my @smooth_primes;
foreach my $p (@{primes(5000)}) {
if ($p == 2) {
push @smooth_primes, $p;
next;
}
my @f1 = factor($p - 1);
my @f2 = factor($p + 1);
if ($f1[-1] <= 5 and $f2[-1] <= 7) {
push @smooth_primes, $p;
}
}
my $h = smooth_numbers(Math::GMPz->new(10)**30, \@smooth_primes);
say "\nFound: ", scalar(@$h), " terms";
my %table;
foreach my $n (@$h) {
$n > 1e12 or next;
$n % 2 == 0 or next;
if (isok($n)) {
say $n;
}
}