Created
December 28, 2016 10:53
-
-
Save nikukyugamer/ff3a04b4eecb98e60fb88203adf28050 to your computer and use it in GitHub Desktop.
fizz buzz by Perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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