Problem 3: Largest prime factor
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the given number?
Solution:
function largestPrimeFactor(number) {
  let maxFactor = number;
  for(let i = 2; i<=Math.sqrt(maxFactor); i++) {
    if(!(maxFactor%i)) {
      let max = largestPrimeFactor(maxFactor/i)
      return i > max ? i : max
    }
  }
  return maxFactor;
}
largestPrimeFactor(10);
Click here to go to the original link of the question.
