psp_from_smooth_primes.pl 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/perl
  2. # Generate pseudoprimes that are product of primes p such that p-1 and p+1 are both B-smooth, for some small bound B.
  3. use 5.020;
  4. use warnings;
  5. use ntheory qw(:all);
  6. use Math::Prime::Util::GMP;
  7. use List::Util qw(shuffle);
  8. use experimental qw(signatures);
  9. use Math::GMPz;
  10. use ntheory qw(:all);
  11. use Math::AnyNum qw(is_smooth);
  12. sub is_lucas_carmichael ($n) {
  13. if ($n > ~0) {
  14. $n = Math::GMPz::Rmpz_init_set_str($n, 10);
  15. }
  16. my $t = $n + 1;
  17. vecall { $t % ($_ + 1) == 0 } Math::Prime::Util::GMP::factor($n);
  18. }
  19. ## p+1 and p-1 are both 7-smooth
  20. #my @a = (3, 5, 7, 11, 13, 17, 19, 29, 31, 41, 71, 97, 127, 251, 449, 4801);
  21. ## p+1 and p-1 are both 11-smooth
  22. #my @a = (3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 41, 43, 71, 89, 97, 109, 127, 197, 199, 241, 251, 449, 769, 881, 4801);
  23. ## p+1 and p-1 are both 13-smooth
  24. #my @a = (3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 41, 43, 53, 71, 79, 89, 97, 109, 127, 131, 181, 197, 199, 241, 251, 337, 449, 701, 727, 769, 881, 1249, 4159, 4801, 8191);
  25. ## p+1 and p-1 are both 17-smooth
  26. #my @a = (3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 41, 43, 53, 71, 79, 89, 97, 103, 109, 127, 131, 181, 197, 199, 239, 241, 251, 307, 337, 449, 701, 727, 769, 881, 1249, 1429, 1871, 4159, 4801, 4999, 8191, 388961);
  27. ## p+1 is 7-smooth, p-1 is not 7-smooth
  28. my @a = (23, 47, 53, 59, 79, 83, 89, 107, 139, 149, 167, 179, 191, 199, 223, 239, 269, 293, 349, 359, 383, 419, 431, 479, 499, 503, 587, 599, 647, 719, 809, 839, 863, 881, 971);
  29. ## p-1 is 7-smooth, p+1 is not 7-smooth
  30. #my @a = (37, 43, 61, 73, 101, 109, 113, 151, 163, 181, 193, 197, 211, 241, 257, 271, 281, 337, 379, 401, 421, 433, 487, 491, 541, 577, 601, 631, 641, 673, 701, 751, 757, 769, 811, 883);
  31. ## p-1 is 3-smooth, p+1 is not 7-smooth
  32. #my @a = (37, 73, 109, 163, 193, 257, 433, 487, 577, 769, 1153, 1297, 1459, 2593, 2917, 3457, 3889, 10369, 12289, 17497, 18433, 39367, 52489, 65537);
  33. ## p+1 is 3-smooth, p+1 is not 7-smooth
  34. #my @a = (23, 47, 53, 107, 191, 383, 431, 647, 863, 971, 1151, 2591, 4373, 6143, 6911, 8191, 8747, 13121, 15551, 23327, 27647, 62207, 73727);
  35. @a = shuffle(@a);
  36. forcomb {
  37. my $c = Math::Prime::Util::GMP::vecprod(@a[@_]);
  38. #if (Math::Prime::Util::GMP::is_pseudoprime($c,2)) {
  39. #if (Math::Prime::Util::GMP::is_carmichael($c)) {
  40. if (is_lucas_carmichael($c)) {
  41. say $c;
  42. }
  43. } scalar(@a), 6;