extra-strong_lucas_not_lucas.pl 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/usr/bin/perl
  2. # Find extra-strong Lucas pseudoprimes that are not regular Lucas pseudoprimes.
  3. # The first few terms are:
  4. # 989, 3239, 27971, 29681, 30739, 31631, 125249, 137549, 137801, 153931
  5. # See also:
  6. # https://oeis.org/A217120 -- Lucas pseudoprimes
  7. # https://oeis.org/A217719 -- Extra strong Lucas pseudoprimes
  8. use 5.020;
  9. use strict;
  10. use warnings;
  11. use Math::Prime::Util::GMP qw(
  12. is_pseudoprime
  13. is_lucas_pseudoprime
  14. is_extra_strong_lucas_pseudoprime
  15. is_almost_extra_strong_lucas_pseudoprime
  16. );
  17. my %seen;
  18. while (<>) {
  19. next if /^\h*#/;
  20. /\S/ or next;
  21. my $n = (split(' ', $_))[-1];
  22. $n || next;
  23. next if ($n < ~0);
  24. #next if length($n) > 40;
  25. is_pseudoprime($n, 2) && next;
  26. is_lucas_pseudoprime($n) && next;
  27. if ( is_extra_strong_lucas_pseudoprime($n)
  28. || is_almost_extra_strong_lucas_pseudoprime($n)) {
  29. say $n if !$seen{$n}++;
  30. }
  31. }
  32. __END__
  33. # Some examples greater than 2^64:
  34. 21979710862205324399
  35. 31155533865320225759
  36. 32614974548912586599
  37. 46675503329187754391
  38. 47137357874632210499
  39. 68891633072323569191
  40. 110010529523011784831
  41. 181792908157826671439
  42. 187961990407258205591
  43. 204775845664488874991
  44. 206459139977493134399
  45. 206560670024345256791
  46. 206675382180674432759
  47. 294453521939438917439
  48. 298428222066624344999
  49. 336947701713570561239
  50. 513398368200012052799
  51. 557700139349287019399
  52. 798909849426402491399
  53. # Some examples with more than 3 factors:
  54. 1441047407316299
  55. 757833929289202499
  56. 27292658179482499859
  57. 76400587170813605849
  58. 137534203921819545569
  59. 299651357354898181499
  60. 635873639357398391459
  61. 688263201326737424489
  62. 849911100465285007379
  63. 850047981592775523011
  64. 903938650523935653059
  65. 2319023344998942960299
  66. 2510072121079439620259
  67. 39383652460474120698899
  68. 84512947066721812244219
  69. 233535954319253909204699
  70. 432509954733989656647779
  71. 4904416886890491872853899
  72. 3039165753384639348162300649999