Hey guys, I have been trying to figure this out for a bit and it’s really been stumping me.
I am trying to find every combination of 6 numbers that = x.
All numbers must be between 1 and 49 so the smallest number would be 21 (1 + 2 + 3 + 4 + 5 + 6) and the largest 279 (44 + 45 + 46 + 47 + 48 + 49)
Example:
Every combination of numbers a + b + c + d + e + f that equals 150
I’m thinking I can do it with a dozen do while loops
Example:
$one = 1;
$two = 2;
$three = 3;
$four = 4;
$five = 5;
$six = 6;
//$num = 1;
do {
$total = $one + $two + $three + $four + $five + $six;
$set = 1;
echo "<tr>";
echo "<td>" . $one . "</td>";
echo "<td>" . $two. "</td>";
echo "<td>" . $three . "</td>";
echo "<td>" . $four . "</td>";
echo "<td>" . $five . "</td>";
echo "<td>" . $six . "</td>";
echo "<td>" . $total . "</td>";
echo "<td>" . $set . "</td>";
echo "</tr>";
$six++;
$num++;
}while($six < 49);
do {
$total = $one + $two + $three + $four + $five + $six;
$set = 2;
echo "<tr>";
echo "<td>" . $one . "</td>";
echo "<td>" . $two. "</td>";
echo "<td>" . $three . "</td>";
echo "<td>" . $four . "</td>";
echo "<td>" . $five . "</td>";
echo "<td>" . $six . "</td>";
echo "<td>" . $total . "</td>";
echo "<td>" . $set . "</td>";
echo "</tr>";
$five++;
$num++;
}while($five < 48);
Etc, etc but there has to be a simpler way.
Thanks for any kind of help.
Cheers!