Given a positive integer ‘n'( 1 <= n <= 1015). Find the largest prime factor of a number.
Input: 6 Output: 3 Explanation Prime factor of 6 are- 2, 3 Largest of them is '3' Input: 15 Output: 5
The approach is simple, just factorise the given number by dividing it with the divisor of a number and keep updating the maximum prime factor. See this to understand more.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Sum of largest prime factor of each number less than equal to n
- Find sum of a number and its maximum prime factor
- Find Largest Special Prime which is less than or equal to a given number
- k-th prime factor of a given number
- N-th prime factor of a given number
- Largest factor of a given number which is a perfect square
- Sum of Maximum and Minimum prime factor of every number in the Array
- Find the total number of composite factor for a given number
- Largest number in [2, 3, .. n] which is co-prime with numbers in [2, 3, .. m]
- Largest number with prime digits
- Largest number that divides x and is co-prime with y
- Prime Factor
- Largest number less than N whose each digit is prime number
- Sum of largest divisible powers of p (a prime number) in a range
- Largest number not greater than N which can become prime after rearranging its digits
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.