gen.pl 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/perl
  2. use 5.014;
  3. use Math::GMPz;
  4. use List::Util qw(uniq);
  5. use ntheory qw(forsemiprimes rootint forprimes factor forsquarefree random_prime divisors gcd next_prime primes);
  6. use Math::Prime::Util::GMP qw(mulint is_pseudoprime vecprod divint sqrtint vecprod is_carmichael sigma);
  7. use Math::AnyNum qw(is_smooth);
  8. use experimental qw(signatures);
  9. #my @primes = factor("10009685197802534744715443494313482401091152723738784642121192679144375616651382814529624339577570705844012088914133917719807197736865507002985078061634472737208255577814479534145444128867519953253569526071446513841337155357225747799360717260975395516046192486881165626392939090421114988200970405960905903");
  10. my @primes = grep { is_smooth($_-1, rootint($_,3)>>1) } @{primes(1000)};
  11. #my @primes = @{primes(1086989-1000, 1086989+1000)};
  12. sub abundancy ($n) {
  13. sigma($n)/$n;
  14. }
  15. my %seen;
  16. sub generate ($root) {
  17. return if $seen{$root}++;
  18. if (length($root) > 45) {
  19. return;
  20. }
  21. my @abundant;
  22. foreach my $p (@primes){
  23. gcd($p, $root) == 1 or next;
  24. my $t = mulint($root, $p);
  25. if (length($t) <= 45 and abundancy($t) > 1.89) {
  26. if (abundancy($t) < 2.1) {
  27. push @abundant, $t;
  28. }
  29. if (is_carmichael($t)) {
  30. say abundancy($t), " -> ", $t;
  31. }
  32. }
  33. }
  34. #say "Generation: ", scalar(@abundant);
  35. foreach my $t (@abundant) {
  36. generate($t);
  37. }
  38. }
  39. #generate(vecprod(3, 5, 17, 23, 29, 43, 53, 89, 113, 127));
  40. #generate(vecprod(3, 5, 17, 23, 29, 53, 89));
  41. #generate("171800042106877185");
  42. generate(vecprod(3, 5, 17, 23, 29, 53, 89, 197));