prog.pl 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/perl
  2. # Composite integers n such that the sum of the Pell numbers A000129(0) + ... + A000129(n-1) is divisible by n.
  3. # https://oeis.org/A270345
  4. # These are composite numbers n such that A048739(n) is divible by n.
  5. # These are composite numbers n such that V_n(2, -1) == 2 (mod n).
  6. # These are composite numbers n such that A002203(n)-2 is divisible by n.
  7. # Identities:
  8. # (A002203(n)-2) / A048739(n-2) = 4
  9. # A048739(n) = (A002203(n+2)-2)/4
  10. # Terms that are not divisible by 4 are 169, 385, 961, 1105, 1121, 3827, 4901, 6265, 6441, 6601, 7107, 7801, 8119, ...
  11. # See also:
  12. # https://en.wikipedia.org/wiki/Lucas_pseudoprime
  13. use 5.020;
  14. use ntheory qw(:all);
  15. use experimental qw(signatures);
  16. local $| = 1;
  17. sub isok ($n) {
  18. is_prime($n) and return;
  19. $n > 1 or return;
  20. my ($U, $V) = lucas_sequence($n, 2, -1, $n);
  21. $V == 2;
  22. }
  23. #~ foreach my $n(..1344) {
  24. #~ print($n, ", ") if isok($n);
  25. #~ }
  26. #~ __END__
  27. my ($V);
  28. my $count = 7714;
  29. foroddcomposites {
  30. (undef, $V) = lucas_sequence($_, 2, -1, $_);
  31. if ($V == 2) {
  32. say "$count $_";
  33. ++$count;
  34. exit if ($count > 10_000);
  35. }
  36. } 7036679161, 1e11;