First, let me start by saying that lotteries are taxes for people who can't do math, but the intellectual challenge of this problem is too much to just ignore.
Let's assume we're doing the letters a through s (i.e. 1 through 19) and we want all possible permutations that meet the following criteria: 1: No repeats. no single letter will be seen more than once in a sequence. 2: The letters will always appear in alphabetic sequence, sinc a b c d e f is equivalent to f e d c b a.
So, we can use 6 for next loops of 1 through 19 each to represent the letters a through s. The first count will start with the outermost loop at 1, but since we need no repeats, and since the letters have to always come in order, we start the next loop at 2, next at 3, 4, 5 then 6.
Also, since the first letter will have to be one from a through n (if the first letter came after n, then there wouldn't be enough letters left to fill in the sequence.) we can count only to 14 for the outermost loop, and 15 for the next, and so on to 19 for the innermost loop.
so, our count structure will look something like this:
$min=1;$max=19;
for ($a=$min+0;$a<$max-5;$a++){
for ($b=$min+1;$b<$max-4;$b++){
if ($b<=$a) continue(1);
for ($c=$min+2;$c<$max-3;$c++){
if ($c<=$b||$c<=$a) continue(1);
for ($d=$min+3;$d<$max-2;$d++){
if ($d<=$c||$d<=$b||$d<=a) continue(1);
for ($e=$min+4;$e<$max-1;$e++){
if ($e<=$d||$e<=$c||$e<=$b||$e<=$a) continue(1);
for ($f=$min+5;$f<$max-0;$f++){
if ($f<=$e||$f<=$d||$f<=$c||$f<=$b||$f<=$a) continue(1);
else print chr($a+96).chr($b+96).chr(96+$c).chr(96+$d).chr$ }
}
}
}
}
}
Now I leave it up to you to rearrange this program so it produces the numbers you want, not a bunch of letters