Skip to content

Instantly share code, notes, and snippets.

@isomorphisms
Created December 9, 2011 02:15
Show Gist options
  • Save isomorphisms/1449812 to your computer and use it in GitHub Desktop.
Save isomorphisms/1449812 to your computer and use it in GitHub Desktop.
fizzbuzz. can I have a cookie now?
#!/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
@isomorphisms
Copy link
Author

!/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment