3 ms·
Just in case anyone was wondering, in Perl 6: sub factorial($n) { my $output = 1; for 1..$n -> $i { $output *= $i; }
by colomon 14y ago
Just in case anyone was wondering, in Perl 6:
sub factorial($n) {
my $output = 1;
for 1..$n -> $i {
$output *= $i;
}
$output;
}
or
sub factorial2($n) {
[*] 1..$n;
}
Pretty anonymous function to add a constant:
-> $x { $x + 7 }
Really short version:
* + 7
Named:
sub plus7($x) {
$x + 7;
}