this is my code but i dont like the multi for ... loops and also if i would like to calculte a different amount of numbers from x numbers i cannot do it with this code i need to change the code for it and i would like it to be more flexible.

B4X:

```
Sub runPos
Dim list1 As List
list1.Initialize
Dim highNumber As Int = 9
Dim toCollectNumber As Int = 6
Dim numberStr As String = "" 'ignore
'start //calculate possibilities
Dim possibilities As Int = 1
For z = 0 To toCollectNumber - 1
possibilities = possibilities * (highNumber - z)
Next
Log(factorial(toCollectNumber))
Log(possibilities / factorial(toCollectNumber))
'end
'get all possibilities (STRING)
For i = 1 To highNumber
For j = 2 To highNumber
For k = 3 To highNumber
For l = 4 To highNumber
For m = 5 To highNumber
For n = 6 To highNumber
Dim item As String = "|" & i & "|" & j & "|" & k & "|" & l & "|" & m & "|" & n & "|"
Dim found As Boolean = False
For Each line As String In list1
If line.Contains("|" & i & "|") And line.Contains("|" & j & "|") And line.Contains("|" & k & "|") And line.Contains("|" & l & "|") And line.Contains("|" & m & "|") And line.Contains("|" & n & "|") Then
found = True
Exit
End If
Next
If found Then Continue
list1.Add(item)
'numberStr = numberStr & item & CRLF
Next
Next
Next
Next
Next
Next
Log("list size: " & list1.Size)
'fx.Clipboard.SetString(numberStr)
End Sub
Sub factorial(number As Int) As Int
Dim returnNr As Int = number
Do Until number <= 1
number = number - 1
returnNr = returnNr * number
Loop
Return returnNr
End Sub
```