Answers for "prime factors of 103"

C#
0

Prime factors of a number

public List<Integer> factorsOf(int n) {
  ArrayList<Integer> factors = new ArrayList<>();

  for (int d = 2; n > 1; d++)
    for (; n % d == 0; n /= d)
      factors.add(d);

  return factors;
}
Posted by: Guest on May-13-2021

C# Answers by Framework

Browse Popular Code Answers by Language