privateintsumFactors(int num) {int sum =0;for (int i =1; i <= num /2; i++) {if (num % i ==0) { sum += i; } }return sum;}publicList<List<Integer>>findAmicableNumbers(int n) {List<List<Integer>> res =newArrayList<>();int[] arr =newint[n];for (int i =2; i < n; i++) { arr[i] =sumFactors(i); }for (int i =0; i < n; i++) {int j = arr[i];if (j < i && i == arr[j]) {res.add(Arrays.asList(i, j)); } }return res;}publicstaticvoidmain(String[] args) {S_amicableNumberLessThanN sol =newS_amicableNumberLessThanN();int n =1000;System.out.println(sol.findAmicableNumbers(n));}