-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog.pl
65 lines (46 loc) · 1.28 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
#!/usr/bin/perl
# Carmichael numbers divisible by the sum of their prime factors, sopfr (A001414).
# https://oeis.org/A309003
use 5.020;
use strict;
use warnings;
use experimental qw(signatures);
use Math::GMPz;
use ntheory qw(:all);
use Math::AnyNum qw(is_smooth);
sub odd_part ($n) {
$n >> valuation($n, 2);
}
my %seen;
my @nums;
while (<>) {
next if /^\h*#/;
/\S/ or next;
my $n = (split(' ', $_))[-1];
$n || next;
length($n) > 15 and next;
if ($n < 3240392401) {
next;
}
next if $seen{$n}++;
# is_smooth($n, 1e7) || next;
is_carmichael($n) || next;
say "Candidate: $n";
if ($n > ~0) {
$n = Math::GMPz->new("$n");
}
push @nums, $n;
}
@nums = sort { $a <=> $b } @nums;
say "There are ", scalar(@nums), " total numbers";
foreach my $n (@nums) {
#say "Testing: $n";
#if (odd_part($n - 1) == odd_part(euler_phi($n))) {
# die "Found counter-example: $n";
#}
if ($n % vecsum(factor($n)) == 0) {
print $n, ", ";
}
}
__END__
3240392401, 13577445505, 14446721521, 84127131361, 203340265921, 241420757761, 334797586201, 381334973041, 461912170321, 1838314142785, 3636869821201, 10285271821441, 17624045440981, 18773053896961, 20137015596061, 24811804945201, 26863480687681, 35598629998801