かっこなし会場
かっこは 0 個。ファイル自身を呼び出しているのでかなり遅い。言語のベンチマークとしてはおもしろい。
#!/usr/bin/perl use strict; use warnings; my $end = shift; my $current = shift || 1; my $factorial = shift || 1; exit if $current > $end; print $current, '! = ', $factorial, $/; $current++; $factorial *= $current; exec 'perl', $0, $end, $current, $factorial;
$ perl foo.pl 20 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 6! = 720 7! = 5040 8! = 40320 9! = 362880 10! = 3628800 11! = 39916800 12! = 479001600 13! = 6227020800 14! = 87178291200 15! = 1307674368000 16! = 20922789888000 17! = 355687428096000 18! = 6.402373705728e+15 19! = 1.21645100408832e+17 20! = 2.43290200817664e+18