extend.pl 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/perl
  2. # Sequence that need more terms:
  3. # https://oeis.org/A064252
  4. # https://oeis.org/A064257
  5. # https://oeis.org/A064258
  6. # https://oeis.org/A064260
  7. # https://oeis.org/A064261
  8. # https://oeis.org/A065700
  9. # https://oeis.org/A065699
  10. # https://oeis.org/A064251
  11. use 5.014;
  12. use ntheory qw(:all);
  13. use Math::GMPz;
  14. # Values of m such that N=(am+1)(bm+1)(cm+1) is a Carmichael number, where a,b,c = 1,2,49.
  15. # https://oeis.org/A064261
  16. #my ($a, $b, $c) = (1, 2, 49);
  17. my ($a, $b) = (1, 2);
  18. for (my $c = 3 ; $c <= 49 ; $c += 2) {
  19. my $t = Math::GMPz::Rmpz_init();
  20. my @terms;
  21. foreach my $m (1 .. 1e9) {
  22. if (is_prime($a * $m + 1) && is_prime($b * $m + 1) && is_prime($c * $m + 1)) {
  23. Math::GMPz::Rmpz_set_ui($t, $a * $m + 1);
  24. Math::GMPz::Rmpz_mul_ui($t, $t, $b * $m + 1);
  25. Math::GMPz::Rmpz_mul_ui($t, $t, $c * $m + 1);
  26. if (is_carmichael($t)) {
  27. push @terms, $m;
  28. last if @terms == 1000;
  29. }
  30. }
  31. }
  32. if (@terms) {
  33. say "\n# Numbers m such that N=(am+1)(bm+1)(cm+1) is a Carmichael number, where a,b,c = 1,2,$c.";
  34. say "@terms";
  35. }
  36. }