Created
December 9, 2011 02:15
-
-
Save isomorphisms/1449812 to your computer and use it in GitHub Desktop.
fizzbuzz. can I have a cookie now?
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
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use feature 'say'; | |
for (my $i = 1; $i <= 100; $i++) { | |
if ($i % 15 == 0 ) { say "fizzbuzz"; } | |
elsif ($i % 3 == 0 ) { say "fizz"; } | |
elsif ($i % 5 == 0 ) { say "buzz"; } | |
else { say $i; } | |
}#end for |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!/usr/bin/perl
use warnings;
use strict;
use feature 'say';
for (my $i = 1; $i <= 100; $i++) {
my $string = '';
if ($i % 3 == 0) { $string .= 'fizz'; }
if ($i % 5 == 0) { $string .= 'buzz'; }
if (length($string)==0 ) { say $i; }
else { say $string; }
}#end for