in reply to Re: First code - Factors
in thread First code - Factors

You could collapse most of that into print "$_\n" for grep { 0 == $no % $_ } @int;, if you wanted to. But I have my doubts whether this is reliable for large numbers, because you'll be comparing zero to a tiny floating-point number, which is usually a bad idea.
What tiny floating-point numbers? '%' will always yield an integer, and since @int doesn't contain numbers exceeding $no, even $no/$_ for @int does not involve floats smaller than 1.

Replies are listed 'Best First'.
Re^3: First code - Factors
by Anonymous Monk on Sep 22, 2010 at 19:40 UTC
    Oh, you're right. I was thinking of the technique of naively dividing a number by a factor, without my paying attention to the code. Thanks!