prog.pl 1007 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/perl
  2. # a(n) is the smallest number k such that factorizations of n consecutive integers starting at k have the same excess of number of primes counted with multiplicity over number of primes counted without multiplicity (A046660).
  3. # https://oeis.org/draft/A323253
  4. #~ a(1) = 4
  5. #~ a(2) = 6
  6. #~ a(3) = 21
  7. #~ a(4) = 844
  8. #~ a(5) = 74849
  9. #~ a(6) = 671346
  10. #~ a(7) = 8870025
  11. # See also:
  12. # https://oeis.org/A072072
  13. use 5.020;
  14. use warnings;
  15. use ntheory qw(:all);
  16. use experimental qw(signatures);
  17. sub excess ($n) {
  18. scalar(factor($n)) - scalar(factor_exp($n));
  19. }
  20. sub score ($n) {
  21. my $t = excess($n);
  22. foreach my $k(1..100) {
  23. if (excess($k + $n) != $t) {
  24. return $k;
  25. }
  26. }
  27. }
  28. my $n = 1;
  29. #my $upto = 30199064929748;
  30. #my $upto = 80566783622;
  31. #my $upto = 300000000000000 + 4*1e6;
  32. my $from = 30199064929748 + 2*1e7;
  33. forcomposites {
  34. while (score($_) >= $n) {
  35. say "a($n) = ", $_;
  36. ++$n;
  37. }
  38. } $from, $from+1e7;
  39. __END__
  40. a(7) = 30199059114825