Problems > Largest Prime Factor > Editorial

Largest Prime Factor — Solution & Editorial

Back to the Problem

Divide out each factor from 2 up to √N; whatever remains above 1 at the end is itself prime and is the answer (else the last factor removed).

Complexity: O(√N)