A problem in two parts:
my $total = calcIt( $N, $depth );
The innermost sum can be replaced by $_ * ( $_ + 1 ) / 2.
Can the rest of the process be replaced by a formula in terms of $N & $depth?
I believe the values produced are related to Binomial coefficients C(n, d). of various dimensions--but that's where I get stuck.
use List::Util qw[ sum ]; $N = 10; print sum map{ sum map{ sum map{ sum map{ sum map{ sum 0 .. $_ } 0 .. $_ } 0 .. $_ } 0 .. $_ } 0 .. $_ } 0 .. $N;; 11440 $N = 20; print sum map{ sum map{ sum map{ sum map{ sum map{ sum 0 .. $_ } 0 .. $_ } 0 .. $_ } 0 .. $_ } 0 .. $_ } 0 .. $N;; 657800
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |