carmichael_lcm_is_carmichael_cached.pl 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/perl
  2. # Generate new Carmichael numbers of the form lcm(a,b),
  3. # where a,b are both B-smooth Carmichael numbers, for some small B.
  4. use 5.020;
  5. use strict;
  6. use warnings;
  7. use Storable;
  8. use Math::GMPz;
  9. use ntheory qw(:all);
  10. use Math::Prime::Util::GMP;
  11. use experimental qw(signatures);
  12. my $carmichael_file = "cache/factors-carmichael.storable";
  13. my $carmichael = retrieve($carmichael_file);
  14. my %table;
  15. sub my_carmichael_lambda ($factors) {
  16. Math::Prime::Util::GMP::lcm(map { Math::Prime::Util::GMP::subint($_, 1) } @$factors);
  17. }
  18. my @c = grep { (split(' ', $carmichael->{$_}))[-1] <= 6e2 } keys %$carmichael;
  19. #~ my @c = grep { (split(' ', $carmichael->{$_}))[0] > 1e9 } keys %$carmichael;
  20. #~ my @c = grep { (split(' ', $carmichael->{$_}))[1] <= 11 } keys %$carmichael;
  21. say "# ", scalar @c;
  22. say "# ", binomial(scalar(@c), 2);
  23. #~ exit;
  24. forcomb {
  25. my $c = Math::Prime::Util::GMP::lcm(@c[@_]);
  26. #~ my $c = Math::Prime::Util::GMP::gcd(@c[@_]);
  27. if ($c > ~0 and not exists $carmichael->{$c} and Math::Prime::Util::GMP::is_carmichael($c)) {
  28. say $c;
  29. $carmichael->{$c} = 1;
  30. }
  31. }
  32. scalar(@c), 2;