Largest Prime Factor
Given an integer n, return its largest prime factor.
Constraints
2 <= n <= 10^12
Trial division up to sqrt(n) is enough
Examples
Input: n = 13195 Output: 29
Input: n = 600851475143 Output: 6857
Practise this challenge
All coding challenges
LetsDiscuss
Loading your session…