Ad
  • Custom User Avatar

    Number of divisors (D) of every number (N) can be calculated as:

    D = (pow_0 + 1)*(pow_1 + 1)* ... *(pow_n + 1) (1)

    where pow_{i} are powers of prime numbers in the source number (N) factorization (N = prime_0**pow_0 + prime_1**pow_1 + ... + prime_m**pow_m). Our task is to minimize N with fixed D, so we should check all possible variants of powers which correspond to (eq. 1) and use the minimum possible prime number for maximum power.

    pow_variants - returns all possible variants of powers which correspond to (eq. 1) sorted in descending order.

    math.prod(PRIMES[i]**p for i, p in enumerate(powers)) - returns minimal possible number for current powers combination