Using prime fatorization was brilliant, I didn't think of that. But still, that solution is based on "trial and error", it's not a fully mathematical answer, mostly because it is not possible to achieve one. Of course one could argue you could build an algorithm to find such answer, like a graph search algorithm (which is, in a way, also trial and error), and that would give a mathematical solution, but still... maybe I should just shut up and not be such a geek. Sorry.