Created
November 30, 2012 23:34
-
-
Save msysyamamoto/4179495 to your computer and use it in GitHub Desktop.
剰余を使わないFizzBuzz
This file contains 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
<?php | |
function fizzbuzz($fs, $bs, $i = 1) | |
{ | |
if ($i <= 100) { | |
$fs[] = $f = array_shift($fs); | |
$bs[] = $b = array_shift($bs); | |
printf('%s', $f . $b) || print $i; | |
echo PHP_EOL; | |
fizzbuzz($fs, $bs, $i + 1); | |
} | |
} | |
fizzbuzz(array('', '', 'Fizz'), array('', '', '', '', 'Buzz')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment