I think you are thinking of prime factorization here. You can stop there to determine primeness but not to determine all factors.@divisors = grep { $number % $_ == 0 } 1 .. sqrt($number);
You somehow miss the second line of my optimized solution. It adds the other half of the divisors. :-)
push @divisors, map {$number == $_*$_ ? () : $number/$_} reverse @divi +sors;
For every divisor above the square root, there is a corresponding divisor below the square root. Symmetrical optimization. :-)
print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!
In reply to Re^3: Finding all divisors of an integer
by Sidhekin
in thread Finding all divisors of an integer
by chiburashka
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |