You are here: Home → Forums → Prime Factors → php modulo int > 2^31?
Add a reply
A 29degrees diversion |
See:
<?php
$z=trim( fgets(STDIN) );
foreach( array(2,3) as $p )
echo" $z%$p == ".($z%$p).", $z/$p == ".($z/$p);
3rd Run:
4294967296%2 == 0, 4294967296/2 == 2147483648, 4294967296%3 == 0, 4294967296/3: 1431655765.3333
4th Run:
4294967295%2 == -1, 4294967295/2 == 2147483647.5, 4294967295%3 == -1, 4294967295/3: 1431655765
Where in the 3rd Run this doesn't matter as the loop never reaches Prime 3, in the fourth Run i allways get a timeout on my script because whether it checks mod(INT,PRIME)==0 or mod(INT,PRIME)<1, it's missing the point.