I don't really understand...
So you are treating the group of 4 numbers as 2 separate groups of 2 and permuting them in turn? If that's what you mean then I don't agree with your number of results - I think it's 2!+2!=4 not 2!*2!=4. So for 9 numbers, 3 groups, we'd permute each set of 3 3! times, over 3 groups, means 3!+3!+3!=18 possible results not 108?
Like so:
Have I misunderstood?Code:123456789 132456789 132465789 132465798 213465798 213546798 213546879 231546879 231564879 231564897 312564897 312645897 312645978 321645978 321654978 321654987 123654987 123456987
So you have 2 variables -- N - number of numbers, and g, number of groups to split them into? Or do you infer the number of groups from N somehow?from here if you give me the idea i will try to make this code for ' n '
like we say there are 9 number and per 3 of them makes permutation,(3! *3!*3! = 108 possible results)
If I've got any of that right, then you need 2 loops -- an outer loop that terminates when there aren't any more permutations, and an inner loop which cycles through the groups. I'd use a for loop for the inner loop (convenient to use the index for calculating the offsets to the various groups), and a while loop for the outer loop. Set a flag in the inner loop if no permutations happened, and use that to control the outer loop.