is_mpz_pseudoprime.pl 597 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/perl
  2. # Try to find a BPSW pseudoprime for the GMP library.
  3. # See also:
  4. # https://gmplib.org/manual/Number-Theoretic-Functions
  5. use 5.020;
  6. use strict;
  7. use warnings;
  8. use experimental qw(signatures);
  9. use Math::GMPz;
  10. my $z = Math::GMPz::Rmpz_init_nobless();
  11. while (<>) {
  12. next if /^\h*#/;
  13. /\S/ or next;
  14. my $n = (split(' ', $_))[-1];
  15. $n || next;
  16. next if $n < ~0;
  17. #next if $n > ~0;
  18. Math::GMPz::Rmpz_set_str($z, $n, 10);
  19. if (Math::GMPz::Rmpz_probab_prime_p($z, 1)) {
  20. die "\nCounter-example: $n\n";
  21. }
  22. }
  23. say "No counter-example found...";