6n.pl 624 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/perl
  2. # Numbers n with property that 6^n is the sum of two consecutive primes.
  3. # https://oeis.org/A165744
  4. use 5.014;
  5. #use ntheory qw(:all);
  6. use Math::Prime::Util::GMP qw(prev_prime next_prime is_prob_prime);
  7. use Math::AnyNum qw(ipow);
  8. # from 3000
  9. foreach my $n(3000..4000) {
  10. say "Testing: $n";
  11. my $pow = ipow(6, $n);
  12. my $ipow = $pow>>1;
  13. my $x = Math::AnyNum->new(next_prime($ipow));
  14. #my $y = next_prime($ipow);
  15. #if ($x + $y == $pow) {
  16. if (is_prob_prime($pow - $x) and $x + prev_prime($ipow) == $pow) {
  17. say "Found: $n";
  18. die "New term: $n" if ($n > 1678);
  19. }
  20. }