Question: Picking up 2 or 3 element subsets for a larger nrger n

Given a large number n

When I say n my elements will be {1,2,3,4..n}

take n, k where k will be 2 or 3

Picking up k  element subsets 

In such a way it will return one subset at a time without storing in list to avoid memory usage more 

A for loop like 

Some place within the code where 

 I will be able to perform my task using  each 2 or 3 element subset

and later forget about it

If we go for function may be we need to go for recursive function in such a way that at each call of function it will produce one 2 element subset I do my work with that and then do my next call of the same function again

Kind help please 

Please Wait...