lucas(n)==2_mod_n.pl 737 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/perl
  2. # Odd integers n such that Lucas V_{1, -1}(n) == 2 (mod n).
  3. # Known terms:
  4. # 1643, 387997, 174819237, 237040185477
  5. # a(4) was found by Giovanni Resta on 02 October 2019.
  6. # Indices of 2 in A213060.
  7. # https://oeis.org/A213060
  8. use 5.036;
  9. use Math::GMPz;
  10. use ntheory qw(:all);
  11. use Math::Prime::Util::GMP qw();
  12. my %seen;
  13. while (<>) {
  14. next if /^\h*#/;
  15. /\S/ or next;
  16. my $n = (split(' ', $_))[-1];
  17. $n || next;
  18. (substr($n, -1) & 1) || next; # n must be odd
  19. #~ if ($n > ((~0) >> 1)) {
  20. #~ $n = Math::GMPz->new("$n");
  21. #~ }
  22. my $v = ($n > ~0) ? Math::Prime::Util::GMP::lucasvmod(1, -1, $n, $n) : lucasvmod(1, -1, $n, $n);
  23. if ($v eq '2') {
  24. say $n;
  25. }
  26. }