Inspired by this question over on Math.
Let the prime factorization of a number, n, be represented as P(n) = 2a x 3b x 5c x ....
(Using x as the multiplication symbol.)
Then the number of divisors of n can be represented as D(n) = (a+1) x (b+1) x (c+1) ....
Thus, we can easily say that the number of divisors of 2n is D(2n) = (a+2) x (b+1) x (c+1) ...,
the number of divisors of 3n is D(3n) = (a+1) x (b+2) x (c+1) ...,
and so on.
Write a program or function that uses these properties to calculate n, given certain divisor inputs.
A set of integers, let's call them w, x, y, z, with all of the following definitions:
- all inputs are greater than 1 --
w, x, y, z > 1
- x and z are distinct --
- x and z are prime --
- w is the number of divisors of xn --
- y is the number of divisors of zn --
For the problem given in the linked question, an input example could be
(28, 2, 30, 3). This translates to
A single integer, n, that satisfies the above definitions and input restrictions. If multiple numbers fit the definitions, output the smallest. If no such integer is possible, output a falsey value.
(w, x, y, z) => output (28, 2, 30, 3) => 864 (4, 2, 4, 5) => 3 (12, 5, 12, 23) => 12 (14, 3, 20, 7) => 0 (or some other falsey value) (45, 13, 60, 11) => 1872 (45, 29, 60, 53) => 4176
- Standard code-golf rules and loophole restrictions apply.
- Standard input/output rules apply.
- Input numbers can be in any order - please specify in your answer which order you're using.
- Input numbers can be in any suitable format: space-separated, an array, separate function or command-line arguments, etc. - your choice.
- Similarly, if output to STDOUT, surrounding whitespace, trailing newline, etc. are all optional.
- Input parsing and output formatting are not the interesting features of this challenge.
- In the interests of sane complexity and integer overflows, the challenge number n will have restrictions such that
1 < n < 100000-- i.e., you don't need to worry about possible answers outside this range.