-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnon-pandigital_carmichael_cached.pl
58 lines (49 loc) · 1.71 KB
/
non-pandigital_carmichael_cached.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
#!/usr/bin/perl
# Largest known non-pandigital Carmichael-number?
# Problem from:
# https://math.stackexchange.com/questions/4727838/largest-known-non-pandigital-carmichael-number
use 5.020;
use strict;
use warnings;
use Storable;
use Math::GMPz;
use ntheory qw(:all);
#use Math::Sidef qw(is_fibonacci);
#use Math::Prime::Util::GMP;
use experimental qw(signatures);
use List::Util qw(uniq);
my $carmichael_file = "cache/factors-carmichael.storable";
my $carmichael = retrieve($carmichael_file);
my $t = Math::GMPz::Rmpz_init_set_ui(0);
my $max = Math::GMPz::Rmpz_init_set_ui(0);
while(my($key, $value) = each %$carmichael) {
my @arr = uniq(split(//, $key));
if (@arr < 9) {
Math::GMPz::Rmpz_set_str($t, $key, 10);
if ($t > $max) {
Math::GMPz::Rmpz_set($max, $t);
say $key;
}
}
}
__END__
1173134064449194642607772961
2707919178335377580229505921
2565725525577577667466525242881
1192630881882960900848281663080001
18009956670998641906961577195758401
6108217232633082681906809606009137921
11684481601509580514689185125598110210401
8540459041545441604854988856176194876049741
24401413084510554423536544004606650836656321
48630936334643334101211481634882249463084001
53896648695167545631657574576486461961799681
79929124221529331502274195427290223331742141
188562163845850384482030300154603824662386561
4873738397513713778074934757543707314307340001
205753133602696292325676133512925929399023762961
166881226771712730402012036273874036332643600717681
2832301991199898344880319739243377178777932393009281
69151952950273521303030336106507193030327190205295772001
29302680383281339084821200381682446212968030489888602212801
24175535728373739778391915425385744974848129389282725172845441