recursive.pl 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 divisors gcd next_prime primes);
  6. use Math::Prime::Util::GMP qw(mulint is_pseudoprime vecprod divint sqrtint vecprod is_carmichael sigma);
  7. use experimental qw(signatures);
  8. my @primes = grep{$_ > 257}factor("93665736194361706290316525877947121434159238044887616153549475393018809779683526688115110040263063154457311074239226112571535724853272104087510616984592710415200871852031984070007895559451233459062578077");
  9. sub abundancy ($n) {
  10. sigma($n)/$n;
  11. }
  12. my %seen;
  13. sub generate ($root) {
  14. return if $seen{$root}++;
  15. if (length($root) > 40) {
  16. return;
  17. }
  18. my @abundant;
  19. foreach my $p (@primes){
  20. gcd($p, $root) == 1 or next;
  21. my $t = mulint($root, $p);
  22. my $ab = abundancy($t);
  23. if (length($t) <= 40 and $ab > 1.9 and $ab < 2.1) {
  24. push @abundant, $t;
  25. if (is_pseudoprime($t, 2)) {
  26. say abundancy($t), " -> ", $t;
  27. }
  28. }
  29. }
  30. #say "Generation: ", scalar(@abundant);
  31. foreach my $t(uniq @abundant) {
  32. generate($t);
  33. }
  34. }
  35. #generate(vecprod(3, 5, 17, 23, 29, 43, 53, 89, 113, 127));
  36. generate(vecprod(3, 5, 17, 23, 29, 43, 53, 89, 113, 127, 157, 257));