aboutsummaryrefslogtreecommitdiff
path: root/challenge-088/miguel-prz/perl/Task088_1.pm
blob: 9e0fac9f58f78871c13a5a4f6c3be36fbcdd7e4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use strict;
use warnings;

#------------------------------------------------------------------------------

sub array_of_product {
    my @result;
    for( my $i=0; $i<@_; $i++ ) {
        my $product = 1;
        for( my $j=0; $j<@_; $j++ ) {
            next if $i == $j;
            $product *= $_[$j];
        }
        push @result, $product;
    }
    return @result;
}

#------------------------------------------------------------------------------

1970;