Skip to content

Instantly share code, notes, and snippets.

@alicraigmile
Created October 31, 2013 20:39
Show Gist options
  • Save alicraigmile/7256728 to your computer and use it in GitHub Desktop.
Save alicraigmile/7256728 to your computer and use it in GitHub Desktop.
My take on the coding challenge, FizzBuzz.
#!/usr/bin/perl
use strict;
# (c) 2013 Ali Craigmile <[email protected]>
# [DONE] "Write a program
# [DONE] that prints the numbers from 1 to 100.
# [DONE] But for multiples of three print “Fizz” instead of the number
# [DONE] and for the multiples of five print “Buzz”.
# [DONE] For numbers which are multiples of both three and five print “FizzBuzz”."
for (my $i=1; $i<=100; $i++) {
if ($i % 15 == 0) {
print "FizzBuzz\n";
} elsif ($i % 5 == 0) {
print "Buzz\n";
} elsif ($i % 3 == 0) {
print "Fizz\n";
} else {
print "$i\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment