You are given a positive integer n greater than 1. Your task is to return its largest prime factor.
A prime factor is a prime number that divides n exactly. If n is itself prime, its largest prime factor is the number itself.
Input: n = 60
Output: 5
Explanation: The prime factors of 60 are 2, 3, and 5. The largest prime factor is 5.
Input: n = 13
Output: 13
Explanation: Since 13 is prime, its only prime factor is 13 itself.
Input: n = 100
Output: 5
Explanation: The prime factorization of 100 is 2 × 2 × 5 × 5, so the largest prime factor is 5.
Sign in to write, run, and submit your solution against the full test suite.