import java.util.ArrayList; import java.util.List; class AchaPrimos { public static boolean primo(int num) { for (int i = 2; i < num; i++) { if (num % i == 0) return false; } return true; } public static List<Integer> fatorar(int x) { List<Integer> numeros = new ArrayList<Integer>(); for (int i = 2; i <= s; i++) { if (primo(i)) { while (aux % i == 0) { aux /= i; numeros.add(i); } } } if (aux != 1 || numeros.isEmpty()) numeros.add(aux); return numeros; } } }
Standard input is empty
36: [2, 2, 3, 3] 60: [2, 2, 3, 5] 120: [2, 2, 2, 3, 5] 144: [2, 2, 2, 2, 3, 3] 97: [97] 128: [2, 2, 2, 2, 2, 2, 2] 15: [3, 5] 2: [2] 7: [7] 1: [1] 0: [0]