Combinations without Repetition


Example: choosing numbers in a lottery. (Order does not matter.)

Preview of this algorithm

Icon Variable
Ask for n with default 0
Icon Output
Print text n = number of items per column
Icon Variable
Ask for t with default 0
Icon Output
Print text t = number of columns
Icon Variable
Set x to 0
Icon Variable
Set r to 1
Icon Variable
Set z to 1
Icon Structure
While x < t
Icon Variable
Set y to n - x
Icon Variable
Set w to t - x
Icon Variable
Set r to r * y
Icon Variable
Set z to z * w
Icon Variable
Set x to x + 1
Icon Structure
End
Icon Variable
Set r to r / z
Icon Output
Print variable r