-
Notifications
You must be signed in to change notification settings - Fork 0
/
carmichael_m-1_is_power.pl
executable file
·66 lines (55 loc) · 1.15 KB
/
carmichael_m-1_is_power.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
#!/usr/bin/perl
# Carmichael numbers n such that n-1 is a perfect power.
# https://oeis.org/A265328
use 5.020;
use strict;
use warnings;
use Math::GMPz;
use ntheory qw(:all);
my %seen;
my $z = Math::GMPz::Rmpz_init();
while (<>) {
next if /^\h*#/;
/\S/ or next;
my $n = (split(' ', $_))[-1];
$n || next;
Math::GMPz::Rmpz_set_str($z, $n, 10);
Math::GMPz::Rmpz_sub_ui($z, $z, 1);
if (Math::GMPz::Rmpz_perfect_power_p($z) and is_carmichael($n)) {
say $n if !$seen{$n}++;
}
#<<<
#~ my $t = Math::GMPz->new($n)**4 + 1;
#~ if (is_carmichael($t)) {
#~ say $t if !$seen{$t}++;
#~ }
#>>>
}
__END__
1729
46657
2433601
2628073
19683001
67371265
110592000001
351596817937
422240040001
432081216001
2116874304001
3176523000001
18677955240001
458631349862401
286245437364810001
312328165704192001
12062716067698821000001
20717489165917230086401
211215936967181638848001
411354705193473163968001
14295706553536348081491001
520417541686202544384000001
32490089562753934948660824001
782293837499544845175052968001
611009032634107957276386802479001
26079495962445633235872174137208001
2612444951766966131992650907329921024001