benoit_primes_2_cached.pl 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/perl
  2. # k-1 for integers k>=4 such that 2^k == 4 (mod k*(k-1)*(k-2)*(k-3)/24).
  3. # https://oeis.org/A337859
  4. # Known terms:
  5. # 3, 5, 37, 44101, 157081, 2031121, 7282801, 8122501, 18671941, 78550201, 208168381, 770810041, 2658625201, 2710529641, 5241663001, 14643783001, 18719308441, 56181482281, 73303609681, 74623302001, 110102454001, 140659081201
  6. # Are there any composite integers in the sequence?
  7. use 5.020;
  8. use strict;
  9. use warnings;
  10. use Storable;
  11. use Math::GMPz;
  12. use ntheory qw(vecall);
  13. use Math::Prime::Util::GMP qw(:all);
  14. use experimental qw(signatures);
  15. sub isok ($k) {
  16. powmod(2, $k, divint(vecprod($k, subint($k, 1), subint($k, 2), subint($k, 3)), 24)) eq '4';
  17. }
  18. (vecall { isok($_ + 1) }
  19. (5, 37, 44101, 157081, 2031121, 7282801, 8122501, 18671941, 78550201, 208168381, 770810041, 2658625201, 2710529641, 5241663001, 14643783001, 18719308441))
  20. || die "error";
  21. my $storable_file = "cache/factors-fermat.storable";
  22. my $fermat = retrieve($storable_file);
  23. while (my ($k, $v) = each %$fermat) {
  24. if (isok(addint($k, 1))) {
  25. say $k;
  26. }
  27. }
  28. __END__
  29. # Also in the sequence are:
  30. 74623302001
  31. 720023604301
  32. 1416018681001
  33. 69738446158921
  34. 1304840825428141
  35. 11704996230181254001