generate_carmichael_cyclic_multiple.pl 627 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/perl
  2. # Find the smallest Carmichael number that is a multiple of a cyclic number.
  3. # See also: https://www.numericana.com/data/crump.htm
  4. use 5.020;
  5. use ntheory qw(:all);
  6. my @list = (753);
  7. foreach my $p(grep { gcd($_, $list[0]) == 1 } @{primes(5000)}) {
  8. my @new = @list;
  9. say "[$#new] Prime: $p";
  10. foreach my $n(@list) {
  11. my $t = $n*$p;
  12. if ($t <= 7281824001) {
  13. if (gcd(euler_phi($t), $t) == 1) {
  14. push @new, $t;
  15. if (is_carmichael($t)) {
  16. die "Found: $t";
  17. }
  18. }
  19. }
  20. }
  21. @list = @new;
  22. }