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
- Smallest prime number missing in an array
- Smallest Special Prime which is greater than or equal to a given number
- Check if the first and last digit of the smallest number forms a prime
- Greatest divisor which divides all natural number in range [L, R]
- Largest Divisor of a Number not divisible by a perfect square
- Next smallest prime palindrome
- Sum and product of k smallest and k largest prime numbers in the array
- Find coordinates of a prime number in a Prime Spiral
- Check if a prime number can be expressed as sum of two Prime Numbers
- Find the smallest number whose digits multiply to a given number n
- Number which has the maximum number of distinct prime factors in the range M to N
- Super Ugly Number (Number whose prime factors are in given set)
- Check if a number is divisible by all prime divisors of another number
- Smallest number by rearranging digits of a given number