Skip to content

Instantly share code, notes, and snippets.

@a-suenami
Created April 11, 2013 03:32
Show Gist options
  • Save a-suenami/5360526 to your computer and use it in GitHub Desktop.
Save a-suenami/5360526 to your computer and use it in GitHub Desktop.
FizzBuzzを一行で。 (forループと改行の出力だけは別。)
<?php
for ($n = 1; $n <= 20; $n++) {
echo (($n % 3 == 0 ? "Fizz" : "") . ($n % 5 == 0 ? "Buzz" : "")) ? (($n % 3 == 0 ? "Fizz" : "") . ($n % 5 == 0 ? "Buzz" : "")) : (string)$n;
echo "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment