Largest Prime Factor — Solution & Editorial
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)
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)