Should be something like

sub p { my @args = @_; # for clarity, more efficient not to copy # initializing this handles the zero argument case my $result = 0; $result += ($args[$_] - ($_ ? $args[$_-1] : 0)) * p(@args[0..($_-1)],@args[($_+1)..(@args-1)]) foreach(0..(@args-1)); return $result; }
note: untested

Ron Steinke

In reply to Re: recursive formula. by rsteinke
in thread recursive formula. by BioGeek

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":