package java_programs;
import java.util.*;

public class GET_FACTORS {
    public static ArrayList<Integer> get_factors(int n) {
        ArrayList<Integer> factors = new ArrayList<>();
        if (n == 1) {
            return factors;
        }
        while (n % 2 == 0) {
            factors.add(2);
            n /= 2;
        }
        int sqrtn = (int) Math.sqrt(n);
        for (int i = 3; i <= sqrtn; i += 2) {
            while (n % i == 0) {
                factors.add(i);
                n /= i;
            }
        }
        if (n > 1) {
            factors.add(n);
        }
        return factors;
    }
}