http://www.perlmonks.org?node_id=435792

Baratski has asked for the wisdom of the Perl Monks concerning the following question:

Hello.

Is there a better way, other than my following example, to find if a number is a multiple of a number?

My klunky way would be to keep subtracting x from y and look for a zero value. This seems like a long haul if I have to keep subtracting say, 4 from 123456789, or something like that.

$x = 4; $y = 123456789; while($y > 0) { $y -= $x; if($y == 0) { #..... } }

Is there a better way?

Thank you.