Skip to content

Instantly share code, notes, and snippets.

@liquidz
Forked from anonymous/fizzbuzz.pl
Created October 11, 2011 13: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 liquidz/1278031 to your computer and use it in GitHub Desktop.
Save liquidz/1278031 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
sub fizzbuzz {
my $n = shift;
for(1 .. $n){
my $res = "";
if($_ % 3 == 0){
$res .= "Fizz";
}
if($_ % 5 == 0){
$res .= "Buzz";
}
if($res eq ""){
$res = $_;
}
print "$res\n";
}
}
fizzbuzz(15);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment