good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^3: All possible number combinations in perlby rovf (Priest) |
on Jun 08, 2012 at 09:27 UTC ( [id://975124]=note: print w/replies, xml ) | Need Help?? |
From your example, it doesn't look like you are interested in combinations (otherwise, 235 would be included in your result), but in complete subsequences of a sequence 1..n. Hence, if N equals 100, the subsequence 42 43 44 45 would be in your result set. Right? In this case, you just need two nested loops (one for the lower bound of the subsequence, one for the upper bound). There are N*N of such subsequences.
-- Ronald Fischer <ynnor@mm.st>
In Section
Seekers of Perl Wisdom
|
|