Largest Prime Factor

Largest Prime Factor

Medium Computer Mathematics Primes & Factorization 27 views
Explanation Complexity

Problem Statement

Print the largest prime factor of n.

Input Format

One integer n.

Output Format

One integer.

Example

84
7

Constraints

2

Input / Output Format

Input Format
One integer n.
Output Format
One integer.
Constraints
2

Examples

Input:
84
Output:
7

Example Solution (Public)

Computer Mathematics
Factor by trial division, track last prime seen. If remaining>1 it is largest.

Official Solution Code

Factor by trial division, track last prime seen. If remaining>1 it is largest.
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.