# File: MathModule.pm
# 
# Stellt mathematische Funktionen zur
# Verfuegung

use strict;
use warnings;

package MathModule;
use base qw(Exporter);
our @EXPORT = qw(faculty);

# berechnet die Fakultaet fuer eine
# gegebene Zahl zwischen 0 und 16
sub faculty {
    my $n = shift;
    return -1 if $n < 0 or $n > 16;
    return 1 if $n == 0;
    return $n*faculty($n-1);
}

