use warnings; use strict; use ntheory qw/forpart/; use List::MoreUtils qw/uniq/; my $sum = shift || 20; my $terms = shift || 4; my $amax = $sum; $amax -= $_ for 1 .. $terms-1; if ($amax > 0) { forpart { print "@_\n" if @_ == uniq @_ } $sum, {n=>$terms, amax=>$amax}; }