MeetCode
Largest Prime Factor
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Run
Submit
Dark
Problem Statement
Solutions
Submissions
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
Input
84
Output
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
Wrap
Copy
Factor by trial division, track last prime seen. If remaining>1 it is largest.
Please
login
to submit solutions.
Editor
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Test Cases
Output
Submission Result
Input
84
Expected Output
7
Compile Output
Error
Output
Please
login
to submit solutions.