Simple Java Code Solution


#1

public class Solution {
public ArrayList allFactors(int A) {
ArrayList ar = new ArrayList<>();
for(int i=1;i<=Math.sqrt(A);i++){
if(A%i == 0){
ar.add(i);
if(i!=Math.sqrt(A)){
ar.add(A/i);
}
}

    }
    Collections.sort(ar);
    return ar;
}

}