Project Euler - Problem 3: Largest prime factor { Why you add max varibale in your solution}

Tell us what’s happening:
I saw you added amax variable in your solution. However, it iI found it useless and it has not any role!

Your code so far

function largestPrimeFactor(number) {
  let prime = 2;
  while (prime <= number) {
    (number % prime == 0) ? number = number / prime : prime++
  return prime


Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Project Euler - Problem 3: Largest prime factor

Link to the challenge:

That is fine you came up with a different solution, but you should not use the ternary operator in place of an if/else statement. It is not the purpose of it.

Also, in the future, do not post a solution.


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.