$n = trim(fgets(STDIN)); for ($i = 1; $i <= (integer)$n; $i++) { $tmp = ""; if ($i%3 === 0) $tmp .= "Fizz"; if ($i%5 === 0) $tmp .= "Buzz"; echo (strlen($tmp) > 0 ? $tmp : (string)$i) . "
"; }