Jump to content

[SOLVED] divisible by 4?


onedumbcoder

Recommended Posts

$max = 100; // some random number to be counted to
$counter = 0; // initialize counter

for ($x = 1; $x < $max; $x++) { // loop to count to whatever
   // % is called modulus it divides $x by 4 and returns a remainder
   if ($x % 4 == 0) { // if the remainder is 0....
      $counter++;     // add 1 to the counter
   } // end if
} // end for

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.