/
fermat_m-1_is_cube.pl
executable file
·67 lines (56 loc) · 1.83 KB
/
fermat_m-1_is_cube.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
#!/usr/bin/perl
# Numbers n such that n^3 + 1 is a 2-pseudoprime (or Sarrus number).
# https://oeis.org/A270840
use 5.020;
use strict;
use warnings;
use Math::GMPz;
use Math::Prime::Util::GMP qw(:all);
my %seen;
while (<>) {
next if /^\h*#/;
/\S/ or next;
my $n = (split(' ', $_))[-1];
$n || next;
if (is_power(subint($n, 1), 3) and is_pseudoprime($n, 2)) {
#say rootint(subint($n, 1), 3), " -> $n" if !$seen{$n}++;
printf("%s^3 + 1 = %s\n", rootint(subint($n, 1), 3), $n) if !$seen{$n}++;
}
#<<<
#~ my $t = powint($n, 3) + 1;
#~ if (is_pseudoprime($t, 2) and !is_prime($t)) {
#~ say $t if !$seen{$t}++;
#~ }
#>>>
}
__END__
12^3 + 1 = 1729
36^3 + 1 = 46657
138^3 + 1 = 2628073
270^3 + 1 = 19683001
546^3 + 1 = 162771337
4800^3 + 1 = 110592000001
7560^3 + 1 = 432081216001
12840^3 + 1 = 2116874304001
14700^3 + 1 = 3176523000001
358200^3 + 1 = 45959653368000001
678480^3 + 1 = 312328165704192001
16139970^3 + 1 = 4204440099079577973001
22934100^3 + 1 = 12062716067698821000001
55058580^3 + 1 = 166907179917730088712001
59553720^3 + 1 = 211215936967181638848001
74371320^3 + 1 = 411354705193473163968001
113068380^3 + 1 = 1445518018084204472472001
116605860^3 + 1 = 1585481317956993310056001
242699310^3 + 1 = 14295706553536348081491001
997521210^3 + 1 = 992582047968915360867561001
1592680320^3 + 1 = 4040041638461720375328768001
1652749200^3 + 1 = 4514616524376898279488000001
3190927740^3 + 1 = 32490089562753934948660824001
5088964800^3 + 1 = 131791785167458780065792000001
6974736756^3 + 1 = 339299689869647426865103569217
9214178820^3 + 1 = 782293837499544845175052968001
77526460200^3 + 1 = 465961317530333691518135208000001
84855997590^3 + 1 = 611009032634107957276386802479001
296551231020^3 + 1 = 26079495962445633235872174137208001
13772593074240^3 + 1 = 2612444951766966131992650907329921024001