I'm having difficulty coming up with an algorithm that will extract all
the divisors of a given expression.
For example...
Input: X * 5 + (Y / ((10 / T) + 15 / W - 20) / 25
Output:
divisor 1 -> ((10 / T) + 15 / W - 20)
divisor 2 -> T
divisor 3 -> W
divisor 4 -> 25
It may be worth noting that the order of the output result doesn't need
to correspond with the order of operations in the given input. So, as
far as I'm concerned, the output result could also be:
divisor 1 -> 25
divisor 2 -> W
divisor 3 -> T
divisor 4 -> ((10 / T) + 15 / W - 20)
The sole reason that I'm in need to extract the divisors of a given
equation is, I need to trap for divide-by-zero prior to evaluating the
expression.
The fact that the expression can contain divisors within divisors
within divisors ad nauseam makes this a difficult puzzle (for me,
anyway).
the divisors of a given expression.
For example...
Input: X * 5 + (Y / ((10 / T) + 15 / W - 20) / 25
Output:
divisor 1 -> ((10 / T) + 15 / W - 20)
divisor 2 -> T
divisor 3 -> W
divisor 4 -> 25
It may be worth noting that the order of the output result doesn't need
to correspond with the order of operations in the given input. So, as
far as I'm concerned, the output result could also be:
divisor 1 -> 25
divisor 2 -> W
divisor 3 -> T
divisor 4 -> ((10 / T) + 15 / W - 20)
The sole reason that I'm in need to extract the divisors of a given
equation is, I need to trap for divide-by-zero prior to evaluating the
expression.
The fact that the expression can contain divisors within divisors
within divisors ad nauseam makes this a difficult puzzle (for me,
anyway).