public class PermGenerator {
static int Fact( int n ) {
static void Swap( int[] arr, int n, int m ) {
static void GenPerms( int n ) {
for ( int i = 0; i < n; i++ )
Console.WriteLine("[" + String.Join(",", arr) + "]");
for ( int i = 2; i < fac; i++ ) {
while ( arr[l] > arr[r] ) {
while ( arr[l] > arr[r] )
Console.WriteLine("[" + String.Join(",", arr) +"]");
Console.WriteLine("[" + String.Join(",", arr) + "]");
public static void Main( string[] args ) {
PermGenerator.GenPerms(perms);