1
$\begingroup$

Given a set $\Omega$ of tuples, for example,

Tuples[{Range[0, 4], Range[0, 3], Range[0, 2]}]

how can I create all numbers on the form $p_1^{t_1}p_2^{t_2}p_3^{t_3}$ where $p_i$ are (prime) numbers and $(t_1,t_2,t_3)\in\Omega$? (This will give all possible dividers of $p_1^4p_2^3p_3^2$.)

It could be done with a basic For loop and splitting the elements into parts etc. but there must be a shorter, better and (much) smarter way to do it. TIA.

$\endgroup$
3
  • 3
    $\begingroup$ Why not just use Divisors[p1^4 * p2^3 * p3^2] ? $\endgroup$
    – flinty
    Jul 28 '20 at 14:02
  • 3
    $\begingroup$ (Times @@ ({p1, p2, p3}^#)) & /@ Tuples[{Range[0, 4], Range[0, 3], Range[0, 2]}] $\endgroup$
    – flinty
    Jul 28 '20 at 14:09
  • $\begingroup$ #1. I did not know of this function. Thank you for solutions. $\endgroup$
    – mf67
    Jul 28 '20 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.