search.pl 724 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/perl
  2. use 5.014;
  3. use warnings;
  4. use ntheory qw(:all);
  5. # Smallest prime q such that, starting with q, there are prime(n)-1 consecutive primes = {1..prime(n)-1} modulo prime(n).
  6. # https://oeis.org/A206333
  7. # Known terms:
  8. # 3, 7, 251, 61223, 23700022897
  9. my $from = prev_prime(59967907);
  10. my @root = $from;
  11. while (@root < 11) {
  12. $from = next_prime($from);
  13. push @root, $from;
  14. }
  15. forprimes {
  16. if ($_ % 13 == 12 and $root[0]%13 == 1) {
  17. my $ok = 1;
  18. foreach my $k(2..11) {
  19. if (($root[$k-1] % 13) != $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;