Skip to content

Instantly share code, notes, and snippets.

@brianveltman
Last active November 17, 2017 19: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 brianveltman/2c2b3faeadf8636ff659d5f93441fd23 to your computer and use it in GitHub Desktop.
Save brianveltman/2c2b3faeadf8636ff659d5f93441fd23 to your computer and use it in GitHub Desktop.
simple fizzbuzz
/* A FizzBuzz assignment with DRY and clean code
Not the fastest nor shortest code, but readable for everyone */

$start = 100;
for ($iteration = 1; $iteration <= $start; $iteration++) {
  $endOfLine = "</br>";
  $dividableByThree = $iteration % 3 === 0;
  $dividableByFive = $iteration % 5 === 0;
    if ($dividableByThree && $dividableByFive) {
          echo "SupportDesk" . $endOfLine;
    } elseif ($dividableByThree) {
          echo "Support" . $endOfLine;
    } elseif ($dividableByFive) {
          echo "Desk" . $endOfLine;
    } else {
          echo $iteration . $endOfLine;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment