Saturday, 29 April 2017

NodeJS incorrect values

From my experience, php code and javascript one can be very portable, but today I found this:

$secret1 = 8992483;
$secret2 = 1785665;
$counter = 3288985389;
for ($i=0; $i<10000000; $i++) {
    $counter = ($counter * $secret1) % $secret2;
}
console.log($counter);

when executed in chrome/nodejs i get 652751, but in other languages like PHP or even C it shoud be: 1281709

What am I doing wrong? :S

Thanks



via Marcos Fernandez Ramos

No comments:

Post a Comment