I want to generate all possible sequence for 49 6 lottery
So I need number sequence for 6 ball drawn from group of 1 to 49.
Can I get logic to generate these sequences?
I want to generate all possible sequence for 49 6 lottery
So I need number sequence for 6 ball drawn from group of 1 to 49.
Can I get logic to generate these sequences?
Here is a well written article that covers the various scenarios of combinations and permutations. It also has a nice list of references at the end of the article.
<?php
$totalOutcomesEnumerated = 0;
for ($ball1 = 1; $ball1 < 45; $ball1++) {
for ($ball2 = $ball1 + 1; $ball2 < 46; $ball2++) {
for ($ball3 = $ball2 + 1; $ball3 < 47; $ball3++) {
for ($ball4 = $ball3 + 1; $ball4 < 48; $ball4++) {
for ($ball5 = $ball4 + 1; $ball5 < 49; $ball5++) {
for ($ball6 = $ball5 + 1; $ball6 < 50; $ball6++) {
// Each iteration of this loop visits a single outcome
$totalOutcomesEnumerated++;
echo $ball1 . ',' . $ball2 . ',' . $ball3 . ',' . $ball4 . ',' . $ball5 . ',' . $ball6 . PHP_EOL;
}
}
}
}
}
}
echo 'Total outcomes : ' . $totalOutcomesEnumerated . PHP_EOL ; // 13983816