Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FizzBuzz implemented in Perl.
#!/usr/bin/env perl
foreach $number (1..100) {
$three = 0;
$five = 0;
if (($number % 3) == 0) {
print 'Fizz';
$three = 1;
}
if (($number % 5) == 0) {
print 'Buzz';
$five = 1;
}
if ($three || $five) {
print "\n";
} else {
print "$number\n";
}
}
@managedkaos

This comment has been minimized.

Copy link
Owner Author

@managedkaos managedkaos commented Aug 8, 2017

$ ./fizzbuzz.pl
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment