FunctionRacerProblemsRace

Largest Prime Factor

EasyMathPython, JavaScript, TypeScript, Java, C++

Return the largest prime number that divides n. For n = 1 return 1.

Example 1

n 13195
returns 29

13195 = 5 * 7 * 13 * 29.

Example 2

n 16
returns 2

Only the prime 2.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems