zsort.pl 524 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/perl
  2. # Filter non-Carmichael numbers.
  3. use 5.020;
  4. use strict;
  5. use warnings;
  6. use ntheory qw(:all);
  7. use Math::GMPz;
  8. my %carmichael;
  9. do {
  10. open my $fh, '<', 'large_carmichael.txt';
  11. while (<$fh>) {
  12. next if /^\h*#/;
  13. /\S/ or next;
  14. my $n = (split(' ', $_))[-1];
  15. $n || next;
  16. $carmichael{$n} = 1;
  17. }
  18. close $fh;
  19. };
  20. while (<>) {
  21. next if /^\h*#/;
  22. /\S/ or next;
  23. my $n = (split(' ', $_))[-1];
  24. $n || next;
  25. say $n if not exists($carmichael{$n});
  26. }