prog.pl 985 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/perl
  2. # a(n) is the least number that has exactly n divisors with sum of digits n.
  3. # https://oeis.org/A359444
  4. # Known terms:
  5. # 1, 20, 60, 440, 1400, 420, 11200, 11440, 324, 58520, 180880, 18480, 585200, 523600, 114240, 1133440, 2420600, 17820
  6. # New terms (a(19)-a(27)):
  7. # 9634240, 9529520, 1659840, 33353320, 71380400, 4748100, 178890320, 228388160, 671328
  8. use 5.020;
  9. use ntheory qw(:all);
  10. my @table;
  11. foreach my $n (1..1e13) {
  12. my %sums;
  13. foreach my $d (divisors($n)) {
  14. $sums{vecsum(todigits($d))}++;
  15. }
  16. foreach my $s (keys %sums) {
  17. if ($s == $sums{$s} and not $table[$s]) {
  18. $table[$s] = 1;
  19. say "$sums{$s} $n";
  20. }
  21. }
  22. }
  23. __END__
  24. 1 1
  25. 2 20
  26. 3 60
  27. 9 324
  28. 6 420
  29. 4 440
  30. 5 1400
  31. 7 11200
  32. 8 11440
  33. 18 17820
  34. 12 18480
  35. 10 58520
  36. 15 114240
  37. 11 180880
  38. 14 523600
  39. 13 585200
  40. 27 671328
  41. 16 1133440
  42. 21 1659840
  43. 17 2420600
  44. 24 4748100
  45. 20 9529520
  46. 19 9634240
  47. 36 12598740
  48. 22 33353320
  49. 23 71380400
  50. 30 73670520
  51. 25 178890320
  52. 26 228388160