Given a number N, find the smallest prime divisor of N.
- Check if the number is divisible by 2 or not.
- Iterate from i = 3 to sqrt(N) and making a jump of 2.
- If any of the numbers divide N then it is the smallest prime divisor.
- If none of them divide, then N is the answer.
Below is the implementation of the above algorithm:
How to efficiently find prime factors of all numbers till n?
Please refer Least prime factor of numbers till n
- Find the k-th smallest divisor of a natural number N
- Number formed after K times repeated addition of smallest divisor of N
- Smallest N digit number with none of its digits as its divisor
- Sum of largest divisor of numbers upto N not divisible by given prime number P
- Smallest divisor D of N such that gcd(D, M) is greater than 1
- Minimum divisor of a number to make the number perfect cube
- Greatest divisor which divides all natural number in range [L, R]
- Largest Divisor of a Number not divisible by a perfect square
- Largest Divisor for each element in an array other than 1 and the number itself
- Max occurring divisor in an interval
- Generating numbers that are divisor of their right-rotations
- Sum of greatest odd divisor of numbers in given range
- Find an integer X which is divisor of all except exactly one element in an array
- Maximum sum after repeatedly dividing N by a divisor
- Optimal Strategy for the Divisor game using Dynamic Programming
- Probability that an arbitrary positive divisor of 10^X is an integral multiple of 10^Y
- Find elements in a given range having at least one odd divisor
- Largest odd divisor Game to check which player wins
- Program to find Greatest Common Divisor (GCD) of N strings
- Queries to return the absolute difference between L-th smallest number and the R-th smallest number
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.