1 public class test
2 {
3 public static void main(String[] args)
4 {
5 Vector<Integer> v = new Vector<>();
6 for(int i = 1; i <= 5; i++)
7 v.add(i);
8 Scanner input= new Scanner(System.in);
9 int k = input.nextInt();
10 int[] solution = new int[k];
11 System.out.println(Permutation(v, solution, 0, k));
12 input.close();
13 }
14
15 public static int Permutation(Vector<Integer> v, int[] solution, int pos, int k)
16 {
17 if(pos == k)
18 {
19 System.out.println(Arrays.toString(solution) + " ");
20 return 1;
21 }
22
23 int count = 0;
24 for(int i = 0; i < v.size(); i++)
25 {
26 int key = v.get(i);
27 solution[pos++] = key;
28 v.remove(i);
29 count += Permutation(v, solution, pos, k);
30 v.add(i, key);
31 pos--;
32 }
33
34 return count;
35 }
36 }