Search code examples
mathnumbersprimesprime-factoringnumber-theory

How do I calculate a number if its number of factors (N) and number of prime factors (K) are given?


How do I calculate a number if its number of factors (N) and number of prime factors (K) are given?

Example: if N = 4 and K = 2 is given then the only possible value will be 6

Explanation : of the above is 6 has 4 factors (1,2,3,6) of which 2 are primes (2,3). So the only possible value is 6.


Solution

  • Any integer number can be represented as product of powers of primes:

    I = 2^p1 * 3^p2 * 5^p3 * 7^p4 * 11^p5 * ....
    

    Total number of all its factors is

    N = (p1+1) * (p2+1) * (p3+1) * ....
         \__________________________/ 
                K multipliers
    

    So you you need to represent the value N as a product of K factors larger than 1.

    Factorize N into primes, group these primes into K groups.

    Imagine you have N=420 with 5 prime factors: 2 2 3 5 7 and K=3. Make groups 2*2, 3*5, 7 (or any other combination) so corresponding powers to make I are 3,14,6

    For example, having N = 12 and K=3, you can represent 12 = 2 * 2 * 3 and use a product of any two primes with a square of a third prime as the number I. The smallest such value is 60 (2^2 * 3 * 5), the next one is 90 (2 * 3^2 * 5) and so on (for example, 3 * 7 * 11^2 is also a solution).

    For the case N = 12 and K=2 you can represent 12 = 3 * 4 and get results as p^2*q^3 or 12 = 2 * 6 and get results as p*q^5 where p,q are distinct primes

    For the case N = 12 and K=4 you cannot represent 12 as product of four integers larger than 1, so it is impossible to produce result with these arguments