Skip to content

Instantly share code, notes, and snippets.

@john-crossley
Created August 24, 2013 09:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john-crossley/6327082 to your computer and use it in GitHub Desktop.
Save john-crossley/6327082 to your computer and use it in GitHub Desktop.
FizzBuzz in PHP
<?php
$i = 1;
$num = mt_rand(100, 1000);
while ($i < $num) {
if ($i % 3 == 0 && $i & 5 == 0) {
echo "FizzBuzz\n";
} else if ($i % 3 == 0) {
echo "Fizz\n";
} else if ($i % 5 == 0) {
echo "Buzz\n";
} else {
echo $i . "\n";
}
$i++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment