Largest Prime Factor
Return the largest prime factor of an integer .
Requirements
- Trial division up to is enough: time.
Constraints
Examples
EXAMPLE WALKTHROUGHseveral factors
A guided view of the published example, not a trace of your code.
INPUT
[13195]TASKlargest_prime_factor()
EXPECTED OUTPUT
29Start with the input values shown in this example.
Example 1 of 3
Input: n = 13195
Output: 29
Explanation: several factors
Input: n = 2
Output: 2
Explanation: smallest prime
Input: n = 97
Output: 97
Explanation: prime
Hint 1
Divide out each factor completely before moving to the next candidate.
Hint 2
Whatever remains above 1 after the loop is itself prime.