Skip to content

Instantly share code, notes, and snippets.

@tomcha
Created August 1, 2013 12:30
Show Gist options
  • Save tomcha/6130904 to your computer and use it in GitHub Desktop.
Save tomcha/6130904 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
sub fizzbuzz{
my $n = shift;
return 'FizzBuzz' if &is_fizz($n) && &is_buzz($n);
return 'Fizz' if &is_fizz($n);
return 'Buzz' if &is_buzz($n);
return $n ;
}
sub is_fizz{
my $num = shift;
return 1 if $num%3 == 0;
}
sub is_buzz{
my $num = shift;
return 1 if $num%5 == 0;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment