Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $counter1 = 1;
- $counter2 = 1;
- $counter3 = 1;
- $nonumber = 0;
- for($i=1; $i<=100; $i++) {
- $word = '';
- $fizz = false;
- $buzz = false;
- $nonumber = false;
- $counter1++;
- $counter2++;
- $counter3++;
- if ($counter1 == 4) {
- $word = 'Fizz<br>';
- $nonumber = true;
- $counter1 = 1;
- $fizz = true;
- }
- if ($counter2 == 6) {
- $nonumber = true;
- $word = 'Buzz<br>';
- $counter2 = 1;
- $buzz = true;
- }
- if ($fizz && $buzz)
- {
- echo 'FizzBuzz<br>';
- } else {
- echo $word;
- }
- if (!$nonumber) {
- echo $i.'<br>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment