#!/usr/bin/env perl
use strict;
use warnings;

sub print_error_message {
    my ($message) = @_;
    print STDOUT "ERROR: " . $message . "!!!\n";
}


print_error_message("something bad happened");
print_error_message("something really horrible happened");
print_error_message("something sort of annoying happened");


sub add_two_numbers {
    my ($x, $y) = @_;
    my $sum = $x + $y;
    return $sum;
}

print add_two_numbers(3, 4) . "\n";
print add_two_numbers(5, 6) . "\n";
print add_two_numbers(7, 8) . "\n";


sub add_two_numbers_and_mult_by_three {
    my ($x, $y) = @_;
    my $sum = add_two_numbers($x, $y);
    my $sum_times_three = $sum * 3;
    return $sum_times_three;
}

print add_two_numbers_and_mult_by_three(3, 4) . "\n";
print add_two_numbers_and_mult_by_three(5, 6) . "\n";
print add_two_numbers_and_mult_by_three(7, 8) . "\n";


sub factorial {
    my ($num) = @_;
    if ($num == 1) {
        return 1;
    } else {
        return $num * factorial($num - 1);
    }
}

foreach my $n (1 .. 10) {
    print factorial($n) . "\n";
}


1;
__END__
