fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static boolean primo(int num){
  11.  
  12. for (int i = 2 ; i < num ; ++i){
  13. if (num % i == 0){
  14. return false;
  15. }
  16. }
  17.  
  18. return true;
  19. }
  20. public static List<Integer> b(int x){
  21. List<Integer> numeros = new ArrayList<Integer>();
  22. int aux = x, i = 2;
  23.  
  24. while (i <= x) {
  25. if(primo(i) && aux % i == 0){
  26. aux /= i;
  27. numeros.add(i);
  28. } else {
  29. i++;
  30. }
  31. }
  32.  
  33. return numeros;
  34. }
  35.  
  36. public static void main(String[] args) {
  37. System.out.println(b(36));
  38. }
  39. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
[2, 2, 3, 3]