n = 5
m = 3
len result[] m
#
proc combinations pos val .
if pos > m
print result[]
return
.
for i = val to pos + n - m
result[pos] = i
combinations pos + 1 i + 1
combinations 1 1