carmichael_multiples_of_cyclic_numbers_upper-bounds_cached.pl 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #!/usr/bin/perl
  2. # Try to find smaller upper-bounds for some terms in given in [1].
  3. # [1] http://www.numericana.com/data/crump.htm
  4. use 5.020;
  5. use strict;
  6. use warnings;
  7. use experimental qw(signatures);
  8. use Storable;
  9. use Math::GMPz;
  10. use ntheory qw(:all);
  11. use Math::Prime::Util::GMP;
  12. use experimental qw(signatures);
  13. my $carmichael_file = "cache/factors-carmichael.storable";
  14. my $carmichael = retrieve($carmichael_file);
  15. my %table = (
  16. 885 => Math::GMPz->new("24354644805191195265"),
  17. 2391 => Math::GMPz->new("174470770903594881"),
  18. 2571 => Math::GMPz->new("435262925087145321"),
  19. 2589 => Math::GMPz->new("401998541941991167041"),
  20. 2595 => Math::GMPz->new("947087538769733505"),
  21. 2685 => Math::GMPz->new("114593508055911048606465"),
  22. 2949 => Math::GMPz->new("13053581557039793157"),
  23. 3147 => Math::GMPz->new("318549090992852721"),
  24. 3327 => Math::GMPz->new("98941967334275513001"),
  25. 3561 => Math::GMPz->new("5989287485839308321"),
  26. 3687 => Math::GMPz->new("524511440578928001"),
  27. 3777 => Math::GMPz->new("1987332185274308097"),
  28. 3921 => Math::GMPz->new("8043938618249590401"),
  29. 3945 => Math::GMPz->new("175151119571122982145"),
  30. 3957 => Math::GMPz->new("2066101438765353669681"),
  31. 4281 => Math::GMPz->new("37632639226277034321"),
  32. 4317 => Math::GMPz->new("31061731865190946305"),
  33. 4395 => Math::GMPz->new("30796418521959806145"),
  34. 4461 => Math::GMPz->new("9986032751063139201"),
  35. 4479 => Math::GMPz->new("206116489352712476721"),
  36. 4569 => Math::GMPz->new("2095688354138593761"),
  37. 4659 => Math::GMPz->new("6186353915948077761"),
  38. 4755 => Math::GMPz->new("8013602942157895592385"),
  39. 5199 => Math::GMPz->new("14273651174491346792001"),
  40. 5205 => Math::GMPz->new("916541202603455265"),
  41. 5469 => Math::GMPz->new("1114028845968724401"),
  42. 5721 => Math::GMPz->new("731330689239874466601"),
  43. 5739 => Math::GMPz->new("1454162635820073015201"),
  44. 5745 => Math::GMPz->new("11247058570079728806193785"),
  45. 5847 => Math::GMPz->new("333659645452179201"),
  46. 5991 => Math::GMPz->new("513225718822306281"),
  47. 6081 => Math::GMPz->new("3719863875476635754001"),
  48. 6117 => Math::GMPz->new("155430091992394720257"),
  49. 6189 => Math::GMPz->new("17175295397421257601"),
  50. 6285 => Math::GMPz->new("6728010826528205985"),
  51. 6297 => Math::GMPz->new("19389827292624042801"),
  52. 6333 => Math::GMPz->new("9807699276298043121"),
  53. 6423 => Math::GMPz->new("1084527196278756082161"),
  54. 6459 => Math::GMPz->new("4249657817506137921"),
  55. 6621 => Math::GMPz->new("192752970457624765761"),
  56. 6801 => Math::GMPz->new("2642845284362940801"),
  57. 6819 => Math::GMPz->new("11595472526856600705"),
  58. 6927 => Math::GMPz->new("4729297330092026854401"),
  59. 6999 => Math::GMPz->new("5544401350974184821"),
  60. 7005 => Math::GMPz->new("602676024377414549745"),
  61. 7017 => Math::GMPz->new("5829210869029084461"),
  62. 7185 => Math::GMPz->new("505228540626753945"),
  63. 7377 => Math::GMPz->new("1043689041704091875652561"),
  64. 7431 => Math::GMPz->new("30090648873754779465"),
  65. 7491 => Math::GMPz->new("1116889871166813381"),
  66. 7635 => Math::GMPz->new("242828376142971345"),
  67. 7737 => Math::GMPz->new("2996101935927155553"),
  68. 7971 => Math::GMPz->new("2996101935927155553"),
  69. 8061 => Math::GMPz->new("332680430305042401"),
  70. 8079 => Math::GMPz->new("87027882027226845393921"),
  71. 8133 => Math::GMPz->new("26459729919429771475281"),
  72. 8331 => Math::GMPz->new("8846470928683112890881"),
  73. 8355 => Math::GMPz->new("6728010826528205985"),
  74. 8511 => Math::GMPz->new("803779319037774333801"),
  75. 8535 => Math::GMPz->new("7054680006064724777745"),
  76. 8709 => Math::GMPz->new("47680537491543886991601"),
  77. 8727 => Math::GMPz->new("86047841876705126601"),
  78. 8805 => Math::GMPz->new("5381407173960696398913345"),
  79. 8817 => Math::GMPz->new("129588850685420778994161"),
  80. 8871 => Math::GMPz->new("7467167622488707212801"),
  81. 8889 => Math::GMPz->new("228249992057250389135001"),
  82. 8895 => Math::GMPz->new("161053591977104597648385"),
  83. 8985 => Math::GMPz->new("3855139981347264164985"),
  84. 8997 => Math::GMPz->new("1776051810626544336705"),
  85. 9069 => Math::GMPz->new("3257507467183865324001"),
  86. 9249 => Math::GMPz->new("20807336597168475201"),
  87. 9267 => Math::GMPz->new("179488857170149499841"),
  88. 9357 => Math::GMPz->new("751190089030052734185"),
  89. 9501 => Math::GMPz->new("10234377578232497043201"),
  90. 9627 => Math::GMPz->new("7047849400095948081"),
  91. 9705 => Math::GMPz->new("13630051725155410947585"),
  92. 9771 => Math::GMPz->new("97629125640896501961"),
  93. 9885 => Math::GMPz->new("22544660102863908989505"),
  94. 9897 => Math::GMPz->new("420671308861831161"),
  95. );
  96. my @cyclic = map { $_ + 0 } keys %table;
  97. my $cyclic_lcm = Math::Prime::Util::GMP::lcm(@cyclic);
  98. my $z = Math::GMPz::Rmpz_init();
  99. while (my ($n, $value) = each %$carmichael) {
  100. if (Math::Prime::Util::GMP::gcd($n, $cyclic_lcm) eq '1') {
  101. next;
  102. }
  103. Math::GMPz::Rmpz_set_str($z, $n, 10);
  104. foreach my $c (@cyclic) {
  105. if (Math::GMPz::Rmpz_divisible_ui_p($z, $c)) {
  106. if (Math::GMPz::Rmpz_cmp($z, $table{$c}) < 0) {
  107. printf("%4d: %25s (was %s)\n", $c, $z, $table{$c});
  108. $table{$c} = Math::GMPz::Rmpz_init_set($z);
  109. }
  110. }
  111. }
  112. }
  113. __END__
  114. 885: 3399464645479365585 (was 24354644805191195265)
  115. 2589: 1457666333074319001 (was 401998541941991167041)
  116. 2595: 26771806123726665 (was 947087538769733505)
  117. 2949: 98362858625230161 (was 13053581557039793157)
  118. 3147: 147227530193090817 (was 318549090992852721)
  119. 3327: 438224275059528441 (was 98941967334275513001)
  120. 3921: 3308014622774231385 (was 8043938618249590401)
  121. 4281: 83031469887726921 (was 37632639226277034321)
  122. 4395: 218395364809636785 (was 30796418521959806145)
  123. 4659: 67813812914197281 (was 6186353915948077761)
  124. 4755: 10615749947367669105 (was 8013602942157895592385)
  125. 5739: 401796891724037601 (was 1454162635820073015201)
  126. 5991: 11963965077257649 (was 513225718822306281)
  127. 6189: 199784592656012001 (was 17175295397421257601)
  128. 6333: 7425044769846048801 (was 9807699276298043121)
  129. 6423: 29451778920576321 (was 1084527196278756082161)
  130. 6459: 110092137342844161 (was 4249657817506137921)
  131. 6801: 59288657066862081 (was 2642845284362940801)
  132. 6819: 11906391780675393 (was 11595472526856600705)
  133. 6999: 825621075523244001 (was 5544401350974184821)
  134. 7017: 350394397155781665 (was 5829210869029084461)
  135. 7971: 174291106521315201 (was 2996101935927155553)
  136. 8133: 147729515368989201 (was 26459729919429771475281)
  137. 8331: 1430818776987924801 (was 8846470928683112890881)
  138. 8511: 3008484874098504321 (was 803779319037774333801)
  139. 8727: 417473276486834481 (was 86047841876705126601)
  140. 8817: 227036755552727121 (was 129588850685420778994161)
  141. 8895: 572646898682000385 (was 161053591977104597648385)
  142. 8985: 1254323866883045505 (was 3855139981347264164985)
  143. 8997: 1013209278771288369 (was 1776051810626544336705)
  144. 9069: 15235791299472129 (was 3257507467183865324001)
  145. 9249: 408667965568184001 (was 20807336597168475201)
  146. 9267: 836886399144313281 (was 179488857170149499841)
  147. 9357: 799514199859612161 (was 751190089030052734185)
  148. 9705: 12463703566675736145 (was 13630051725155410947585)
  149. 9771: 101817952350880305 (was 97629125640896501961)
  150. 9885: 5954666714900228865 (was 22544660102863908989505)
  151. 885: 23637590197922787585 (was 24354644805191195265)
  152. 8985: 30796418521959806145 (was 3855139981347264164985)
  153. 8895: 1776051810626544336705 (was 161053591977104597648385)
  154. 9885: 24711257219664352065 (was 22544660102863908989505)
  155. 8895: 99048817349242963665 (was 1776051810626544336705)