Skip to content

Instantly share code, notes, and snippets.

@managedkaos
Created August 8, 2017 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save managedkaos/ed9ed34bf4960afca43641b42a063039 to your computer and use it in GitHub Desktop.
Save managedkaos/ed9ed34bf4960afca43641b42a063039 to your computer and use it in GitHub Desktop.
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
Copy link
Author

$ ./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