search.pl 881 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/perl
  2. # Primes p such that, starting with p, 10 consecutive primes = {1,2,3,4,5,6,7,8,9,10} modulo 11.
  3. # https://oeis.org/A338374
  4. use 5.014;
  5. use warnings;
  6. use ntheory qw(:all);
  7. # New terms found:
  8. # 1053978912361, 1113788109127, 1188162419291, 1562407603483
  9. my $from = prev_prime(715117260463-1e7);
  10. my @root = $from;
  11. while (@root < 9) {
  12. $from = next_prime($from);
  13. push @root, $from;
  14. }
  15. forprimes {
  16. if ($_ % 11 == 10 and $root[0]%11 == 1) {
  17. my $ok = 1;
  18. foreach my $k (2..9) {
  19. if (($root[$k-1] % 11) != $k) {
  20. $ok = 0;
  21. last;
  22. }
  23. }
  24. say $root[0] if $ok;
  25. }
  26. push @root, $_;
  27. shift @root;
  28. } next_prime($from), 1e14;
  29. __END__
  30. 715117260463
  31. 1053978912361
  32. 1113788109127
  33. 1188162419291
  34. 1562407603483
  35. ^C
  36. perl x.pl 5762.19s user 6.53s system 98% cpu 1:37:21.95 total