public static ArrayList<Integer> getDivisors(int n){
ArrayList<Integer> divisors = new ArrayList<>();
//without 1 or n
for (int i = 2; i * i <= n; ++i)
if (n % i == 0) {
divisors.add(i);
if (i != n / i) divisors.add(n / i);
}
return divisors;
}
Code Example |
---|
:: |
:: |
:: |
:: |
:: |
:: |
Javascript :: |
:: |
:: |
:: |
Javascript :: |
:: |
:: |
:: |
:: |
:: |
:: |
:: |
:: |
:: |
Javascript :: |
:: |
:: |
:: |
:: |
:: |
:: |
:: |
:: |
:: |