-
Notifications
You must be signed in to change notification settings - Fork 0
/
carmichael_in_range_cached.pl
38 lines (28 loc) · 1.13 KB
/
carmichael_in_range_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
#!/usr/bin/perl
# List Carmichael numbers in a given range.
# Problem from:
# https://math.stackexchange.com/questions/4734978/how-can-we-find-a-carmichael-number-near-a-huge-given-number
use 5.020;
use strict;
use warnings;
use Storable;
use Math::GMPz;
use ntheory qw(:all);
#use Math::Sidef qw(is_over_psp);
use Math::Prime::Util::GMP;
use experimental qw(signatures);
my $carmichael_file = "cache/factors-carmichael.storable";
my $carmichael = retrieve($carmichael_file);
my $min = "9999999999999999999999999999796847326318726073975133650980786082646990292703172311852106037044385201";
my $max = "10000000000000000000000000000090165987523064535571479173405047627125202459134286779355757424137024721";
#my $min = "9999999999999999999999999995194780645298842465772438047052058885837645928421429394846343577780058169";
#my $max = "10000000000000000000000000000405929367865700162694655745350302085810080768959837103297359653235421369";
while(my($key, $value) = each %$carmichael) {
if (
Math::Prime::Util::GMP::cmpint($key, $min) > 0 and
Math::Prime::Util::GMP::cmpint($key, $max) < 0
) {
say $key;
}
}
__END__