Given two numbers M and N. The task is to print the number which has the maximum number of distinct prime factors of numbers in range M and N. If there exist multiple numbers, print the smallest one.
Input: a=4, b=10
Number of distinct Prime Factors of 4 is 1
Number of distinct Prime Factors of 5 is 1
Number of distinct Prime Factors of 6 is 2
Number of distinct Prime Factors of 7 is 1
Number of distinct Prime Factors of 8 is 1
Number of distinct Prime Factors of 9 is 1
Number of distinct Prime Factors of 10 is 2
Input: a=100, b=150
The approach is to use Sieve of Erathosthenes. Create a factorCount array to store the the number of distinct prime factors of a number. While marking the number as prime, increment the count of prime factors in its multiples. In the end, get the maximum number stored in the factorCount array which will be the answer.
Below is the implementation of the above approach:
- Number of distinct prime factors of first n natural numbers
- Number with maximum number of prime factors
- Maximum number of unique prime factors
- Super Ugly Number (Number whose prime factors are in given set)
- Check whether a number has exactly three distinct factors or not
- Queries to find whether a number has exactly four distinct factors or not
- Prime factors of a big number
- Sum of Factors of a Number using Prime Factorization
- Distinct Prime Factors of Array Product
- Product of unique prime factors of a number
- Number of steps to convert to prime factors
- C Program for efficiently print all prime factors of a given number
- Efficient program to print all prime factors of a given number
- Sort an array according to the increasing count of distinct Prime Factors
- Count occurrences of a prime number in the prime factorization of every element from the given range
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.