use ntheory qw/divisors/;
sub proper_divisors {
  my $n = shift;
  
  return 1 if $n == 0;
  my @d = divisors($n);
  pop @d;  
  @d;
}
say "$_: ", join " ", proper_divisors($_) for 1..10;

my($max,$ind) = (0,0);
for (1..20000) {
  my $nd = scalar proper_divisors($_);
 ($max,$ind) = ($nd,$_) if $nd > $max;
}
say "$max $ind";

{
  use List::Util qw/max/;
  no warnings 'numeric';
  say max(map { scalar(proper_divisors($_)) . " $_" } 1..20000);
}