super-poulet_conjecture_thomas.pl 916 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/perl
  2. use 5.014;
  3. use Math::GMPz;
  4. use ntheory qw(is_prime forprimes);
  5. use Math::Prime::Util::GMP qw(is_pseudoprime divisors powmod);
  6. # Checked up to 57719
  7. # Super-poulet up to p=359
  8. my $t = Math::GMPz->new(0);
  9. my $u = Math::GMPz->new(0);
  10. my $v = Math::GMPz->new(0);
  11. forprimes {
  12. my $p = $_;
  13. if (is_prime(($p - 1) >> 1)) {
  14. print "Testing: $p\n";
  15. Math::GMPz::Rmpz_ui_pow_ui($t, 2, $p - 1);
  16. Math::GMPz::Rmpz_sub_ui($t, $t, 1);
  17. Math::GMPz::Rmpz_divexact_ui($t, $t, 3);
  18. my @divisors = map { Math::GMPz->new($_) } divisors($t);
  19. shift @divisors;
  20. foreach my $d (@divisors) {
  21. powmod(2, $d, $d) eq '2'
  22. or die "error for p=$p and d=$d"
  23. }
  24. #~ if (is_pseudoprime($t, 2)) {
  25. #~ ## ok
  26. #~ }
  27. #~ else {
  28. #~ die "counter-example for p=$p";
  29. #~ }
  30. }
  31. } 10, 1e6;