in reply to 1,000 bucks

If I understand the problem correctly, then
my @dispersal; my $maxpow = int(log($cash)/log(2) - 1); @dispersal = map(2**$_, 0..$maxpow); $dispersal[$#dispersal+1] = $cash - 2**($maxpow +1)+1; my @envelope = sort { $a <=> $b } @dispersal;
should correctly generate @envelope, although there is no need for @dispersal anymore.