Inspired by this question over on Math.
Let the prime factorization of a number, n, be represented as: \$P(n) = 2^a\times3^b\times5^c\times\cdots\$. Then the number of divisors of n can be represented as \$D(n) = (a+1)\times(b+1)\times(c+1)\times\cdots\$. Thus, we can easily say that the number of divisors of \$2n\$ is \$D(2n) = (a+2)\times(b+1)\times(c+1)\times\cdots\$,
the number of divisors of \$3n\$ is \$D(3n) = (a+1)\times(b+2)\times(c+1)\times\cdots\$,
and so on.
Challenge
Write a program or function that uses these properties to calculate \$n\$, given certain divisor inputs.
Input
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\ne z\$
- \$x\$ and \$z\$ are prime -- \$P(x)=x, D(x)=2, P(z)=z \text{ and } D(z)=2\$
- \$w\$ is the number of divisors of \$xn\$ -- \$D(xn)=w\$
- \$y\$ is the number of divisors of \$zn\$ -- \$D(zn)=y\$
For the problem given in the linked question, an input example could be \$(28, 2, 30, 3)\$. This translates to \$D(2n)=28\$ and \$D(3n)=30\$, with \$n=864\$.
Output
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.
Examples:
(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
Rules:
- 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.