y.pl 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #!/usr/bin/perl
  2. use 5.014;
  3. use Math::GMPz;
  4. use List::Util qw(uniq);
  5. use ntheory qw(forsemiprimes forprimes factor forsquarefree random_prime euler_phi );
  6. use Math::Prime::Util::GMP qw(mulint is_pseudoprime vecprod divint sqrtint divisors gcd is_carmichael);
  7. # 2435279804766429985, 1114090435183709985, 7626934787034827265, 5092454223678002545, 13294381492836585505, 1886616373665, 5473367446820370945, 180950795673242145, 3193231538989185, 916541202603455265, 11947816523586945, 101817952350880305, 1177908521713261185, 171800042106877185
  8. # 9744543540935384545, 10186034230241370865, 10885189367088417745, 11356964096926592145, 11595472526856600705, 12275497073183645665, 12376763082073211185, 12525679299253814785, 13294381492836585505, 14631273312068834785, 15131182782493999585, 15157968873827062465, 16888413473957767105, 17215556534723568385, 17445622572008652385, 18329749222420733505
  9. #~ 12376763082073211185
  10. #~ 1180617122678545373185
  11. #~ 345319996314995065
  12. #~ 292561243007134465
  13. #~ 12376763082073211185
  14. #~ 1180617122678545373185
  15. #~ 1399093241875807699585
  16. #~ 573852931410299905
  17. #~ 1370294210266345
  18. #~ 9768827424988773505
  19. #~ 29582577574410161665
  20. #~ 305244070146997345
  21. #~ 5486206558145814865
  22. #~ 345319996314995065
  23. #~ 292561243007134465
  24. #~ 63238598993791585
  25. #~ 9768827424988773505
  26. #~ 32379807987407561422105
  27. #~ 4281332081515547439745
  28. #~ 12376763082073211185
  29. #~ 29582577574410161665
  30. #~ 1227189372830785
  31. #~ 8074371355371685
  32. #~ 1399093241875807699585
  33. #~ 219588765971746167938305
  34. #~ 3904542189035075088865
  35. #~ 1031925092561764182145
  36. #~ 1533250834894400523265
  37. #~ 32379807987407561422105
  38. #~ 66497283692022179297665
  39. #~ 828696209007880663751665
  40. #~ 242746392608701345
  41. #~ 104374820521710440065
  42. #~ 4281332081515547439745
  43. #~ 11956408212534751066465
  44. #~ 1370294210266345
  45. # 2333379336546216408131111533710540349903201, 130912961974316767723865201454187955056178415601, 60977817398996785
  46. my %seen;
  47. my $psp = "828696209007880663751665";
  48. my $limit = sqrtint($psp);
  49. #my $gcd = 7313655;
  50. #my $gcd = 4381310850645;
  51. #my $gcd = 174766108521378405;
  52. #my $gcd = 77728835801292945;
  53. #my $gcd = 113375180882140665;
  54. #my $gcd = 495088126122885;
  55. #my $gcd = 34498510635;
  56. #my $gcd = "19976310800932286865"; # record
  57. #my $gcd = "7051637712729097263345";
  58. my $gcd = vecprod(grep{ $_<50 }factor($psp));
  59. #my $gcd = vecprod(5, 7, 13, 17, 19, 23);
  60. #my $gcd = "119241686273722855330215";
  61. my @squarefree;
  62. forsquarefree {
  63. if ($_ % 2 == 1 and $_ > 1 and gcd($_, $psp) == 1 and gcd(euler_phi($_), $_) == 1) {
  64. push @squarefree, $_;
  65. }
  66. } 1e7;
  67. #push @squarefree, grep{ $_>1 } divisors("6283365899669117794965");
  68. #push @squarefree, grep{ $_>1 } divisors("19976310800932286865");
  69. #push @squarefree, grep{$_>1} divisors("480185024160041299368309995874402451");
  70. push @squarefree, grep{$_>1 and gcd($_, $psp) == 1 and gcd(euler_phi($_), $_) == 1 } divisors("119241686273722855330215");
  71. @squarefree = uniq(@squarefree);
  72. if (is_carmichael($psp)) {
  73. say $psp;
  74. }
  75. foreach my $p(divisors($psp)) {
  76. $p > 1 or next;
  77. last if ($p > $limit);
  78. next if (gcd($p, $gcd) > 1);
  79. my $n = divint($psp, $p);
  80. for (@squarefree) {
  81. if (is_carmichael(mulint($n, $_))) {
  82. say mulint($n, $_) if !$seen{mulint($n, $_)}++;
  83. }
  84. }
  85. }
  86. __END__
  87. foreach my $n(1..1e6) {
  88. my @copy = @factors;
  89. #$copy[-1] = 3*$n+1;
  90. #$copy[-1] = 2*$n+1;
  91. #$copy[-2] = 4*$n+1;
  92. #$copy[-2] = 2*$n+1;
  93. $copy[rand @copy] = random_prime(1e4);
  94. $copy[rand @copy] = random_prime(1e4);
  95. #$copy[rand @copy] = random_prime(1e4);
  96. #$copy[rand @copy] = 2*int(rand(1e3))+1;
  97. #$copy[-3] = 2*int(rand(1e9))+1;
  98. #$copy[-2] = 3*$n+1;
  99. #$copy[-1] = 1;
  100. #$copy[rand(@copy-9)+8] =
  101. if (is_pseudoprime(vecprod(@copy), 2)) {
  102. if (vecprod(@copy) ne $psp) {
  103. say vecprod(@copy);
  104. }
  105. }
  106. }
  107. exit;
  108. my @psp = qw(
  109. 4788772759754985
  110. 38353281032877674865
  111. 2638294879881771254145
  112. 24773130788808935997465
  113. 39898386437874778336787265
  114. 85866492509341408342261785
  115. 198408004487570768403697185
  116. );
  117. forsquarefree {
  118. #if ($_ % 80 == 9) {
  119. if ($_ % 2 == 1 and $_ > 1) {
  120. foreach my $n(@psp) {
  121. if (is_pseudoprime(mulint($n, $_), 2)) {
  122. say mulint($n, $_);
  123. }
  124. #~ my ($p, $q) = factor($_);
  125. #~ $n = Math::GMPz->new($n);
  126. #~ if ($n % $p == 0) {
  127. #~ if (is_pseudoprime(($n/$p)*$q, 2)) {
  128. #~ say (($n/$p)*$q);
  129. #~ }
  130. #~ }
  131. #~ if ($n % $q == 0) {
  132. #~ if (is_pseudoprime(($n/$q)*$p, 2)) {
  133. #~ say (($n/$q)*$p);
  134. #~ }
  135. #~ }
  136. }
  137. }
  138. } 1e7;
  139. __END__