search.pl 954 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/perl
  2. use 5.014;
  3. use warnings;
  4. use ntheory qw(:all);
  5. # Primes p such that 8 consecutive primes starting with p are {1,2,3,4,5,6,7,8} modulo 13.
  6. # https://oeis.org/A338394
  7. # Known terms:
  8. # 5129602609, 40602028559, 69528307577, 129007460609, 236659873633, 322320688171, 371170549153, 390581208473, 441568239503, 651686524243
  9. # New terms found:
  10. #~ 651686524243
  11. #~ 761457812389
  12. #~ 807722926973
  13. #~ 855088513163
  14. #~ 855969933859
  15. #~ 977398008289
  16. #~ 1034360135849
  17. #~ 1079253721703
  18. my $from = prev_prime(651686524243-1e6);
  19. my @root = $from;
  20. while (@root < 7) {
  21. $from = next_prime($from);
  22. push @root, $from;
  23. }
  24. forprimes {
  25. if ($_ % 13 == 8 and $root[0]%13 == 1) {
  26. my $ok = 1;
  27. foreach my $k (2..7) {
  28. if (($root[$k-1] % 13) != $k) {
  29. $ok = 0;
  30. last;
  31. }
  32. }
  33. say $root[0] if $ok;
  34. }
  35. push @root, $_;
  36. shift @root;
  37. } next_prime($from), 1e14;