Largest Prime Factor
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
1 <= n <= 10**6
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.