-
-
Save fabiocicerchia/80b6937d316660a05eb6e54579b73d2e to your computer and use it in GitHub Desktop.
A different (...veeeery different) approach to the good old PHP FizzBuzz test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
if ($argc !== 2 || !ctype_digit($argv[1])) | |
die('You must specifiy only one parameter: the max number as an integer' . PHP_EOL); | |
for ($input = (int) $argv[1], $i = 0; $i < $input; ) echo ([ | |
0 => 'FizzBuzz', | |
3 => 'Fizz', 6 => 'Fizz', 9 => 'Fizz', 12 => 'Fizz', | |
5 => 'Buzz', 10 => 'Buzz', | |
][++$i % 15] ?? $i) . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment