prog.pl 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/perl
  2. # Numbers k such that the arithmetic mean of the first k squarefree numbers is an integer.
  3. # https://oeis.org/A355544
  4. # Known terms:
  5. # 1, 3, 6, 37, 75, 668, 1075, 37732, 742767, 1811865, 3140083, 8937770, 108268896, 282951249, 633932500, 1275584757
  6. # New term found (it took 7 hours to find it):
  7. # 60455590365
  8. # Proof:
  9. # the 60455590365-th squarefree number is 99445459943.
  10. # the sum of all squarefree numbers <= 99445459943, is 3006016997918608257300, which is divisible by 60455590365.
  11. # PARI/GP program:
  12. # upto(n) = my(s=0,k=0); forsquarefree(m=1, n, s+=m[1]; k+=1; if(s%k == 0, print1(k, ", ")));
  13. use 5.020;
  14. use strict;
  15. use warnings;
  16. use Math::GMPz;
  17. use ntheory qw(:all);
  18. my $k = 1;
  19. my $z = Math::GMPz::Rmpz_init_set_ui(0);
  20. forsquarefree {
  21. Math::GMPz::Rmpz_add_ui($z, $z, $_);
  22. if (Math::GMPz::Rmpz_divisible_ui_p($z, $k)) {
  23. say $k;
  24. }
  25. ++$k;
  26. } 1e14;
  27. __END__
  28. 1
  29. 3
  30. 6
  31. 37
  32. 75
  33. 668
  34. 1075
  35. 37732
  36. 742767
  37. 1811865
  38. 3140083
  39. 8937770
  40. 108268896
  41. 282951249
  42. 633932500
  43. 1275584757
  44. 60455590365