Skip to content

Instantly share code, notes, and snippets.

@nikukyugamer
Created December 28, 2016 10:53
Show Gist options
  • Save nikukyugamer/ff3a04b4eecb98e60fb88203adf28050 to your computer and use it in GitHub Desktop.
Save nikukyugamer/ff3a04b4eecb98e60fb88203adf28050 to your computer and use it in GitHub Desktop.
fizz buzz by Perl
my $endval = $ARGV[0];
my $fizz;
my $buzz;
foreach my $i (1 .. $endval) {
$fizz = $i % 3;
$buzz = $i % 5;
if ($fizz == 0 and $buzz == 0) {
print "FizzBuzz";
}
elsif ($fizz == 0) {
print "Fizz";
}
elsif ($buzz == 0) {
print "Buzz";
}
else {
print "$i";
}
print "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment