carmichael-bernoulli_kn_numbers_cached.pl 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/usr/bin/perl
  2. # An interesting subset of Carmichael numbers, defined by Tomasz Ordowski.
  3. # Problem #1:
  4. # Let D_k be the denominator of Bernoulli number B_k.
  5. # Are there numbers n > 3 such that D_{n-1} = 2n ?
  6. # Equivalently, Product_{p prime, p-1|n-1} p = 2n.
  7. # If so, it must be a Carmichael number divisible by 3.
  8. # Problem #2:
  9. # Are there Carmichael numbers n where D_{n-1} = 6n?
  10. # Two Carmichael numbers found by Amiram Eldar:
  11. # 310049210890163447, 18220439770979212619, ...
  12. #
  13. use 5.020;
  14. use strict;
  15. use warnings;
  16. use Storable;
  17. use ntheory qw(:all);
  18. use Math::Prime::Util::GMP;
  19. use experimental qw(signatures);
  20. my $storable_file = "cache/factors-carmichael.storable";
  21. my $carmichael = retrieve($storable_file);
  22. while (my ($n, $value) = each %$carmichael) {
  23. my $len = length($n);
  24. next if $len > 35;
  25. #~ my @factors = split(' ', $value);
  26. #~ @factors == 3 or next;
  27. # Problem 1 condition
  28. #~ Math::Prime::Util::GMP::modint($n, 3) == 0 or next;
  29. my $nm1 = Math::Prime::Util::GMP::subint($n, 1);
  30. # Product_{p-1|n-1, p prime} p
  31. my @primes = grep { is_prime($_) } map { Math::Prime::Util::GMP::addint($_, 1) } Math::Prime::Util::GMP::divisors($nm1);
  32. my $bern_den = Math::Prime::Util::GMP::vecprod(@primes);
  33. # Are there Carmichael numbers such that D_{n-1} = 2n ?
  34. #~ if ($bern_den eq Math::Prime::Util::GMP::mulint($n, 2)) { # problem 1
  35. #~ say $n;
  36. #~ }
  37. # Are there Carmichael numbers n where D_{n-1} = 6n?
  38. if ($bern_den eq Math::Prime::Util::GMP::mulint($n, 6)) { # problem 2
  39. say $n;
  40. }
  41. # Are there Carmichael numbers m such that D_{m-1} = 2(m-2)m ?
  42. #~ if ($bern_den eq Math::Prime::Util::GMP::vecprod(2, $n, Math::Prime::Util::GMP::subint($n, 2))) { # problem 3
  43. #~ say $n;
  44. #~ }
  45. # Are there Carmichael numbers m such that D_{m-1} = 2*p*m with prime p > 3?
  46. #~ if (Math::Prime::Util::GMP::modint($bern_den, $n) == 0) { # problem 4
  47. #~ my $t = Math::Prime::Util::GMP::divint($bern_den, $n);
  48. #~ if (Math::Prime::Util::GMP::modint($t, 2) == 0) {
  49. #~ my $p = Math::Prime::Util::GMP::divint($t, 2);
  50. #~ if (Math::Prime::Util::GMP::is_prime($p)) {
  51. #~ say "[$p] $n";
  52. #~ }
  53. #~ }
  54. #~ }
  55. }
  56. __END__
  57. # Some extra terms for problem #2 (not necessarily consecutive)
  58. 326454636194318621086787
  59. 1789416066515261322576456299
  60. 5271222682189523956137705530039
  61. 31102303189601659841480317050599