Skip to content

Instantly share code, notes, and snippets.

@lukasbestle
Created August 31, 2014 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukasbestle/12f261293ab8901463dd to your computer and use it in GitHub Desktop.
Save lukasbestle/12f261293ab8901463dd to your computer and use it in GitHub Desktop.
Fizz Buzz Test in PHP
<?php
for($i = 1; $i <= 100; $i++) {
$found = false;
// Divisible by 3
if($i % 3 == 0) {
echo 'Fizz';
$found = true;
}
// Divisible by 5
if($i % 5 == 0) {
echo 'Buzz';
$found = true;
}
// Neither
if(!$found) {
echo $i;
}
// Echo trailing newline
echo "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment