2
$\begingroup$

FactorInteger can be used to perform prime factorization:

FactorInteger[5^2 7^3 11^4]

Results in:

{{5,2},{7,3},{11,4}}

Is there a function that given an integer will return the value of a given prime factor raised to its power?

E.g. let's say the function is F:

F[5^2 7^3 11^4, 5]    returns: 5^2
F[5^2 7^3 11^4, 7]    returns: 7^3
F[5^2 7^3 11^4, 11]   returns: 11^4

Also, is there a function that will return the power of a given prime?

E.g. let's say the function is G:

G[5^2 7^3 11^4, 5]    returns: 2
G[5^2 7^3 11^4, 7]    returns: 3
G[5^2 7^3 11^4, 11]   returns: 4
$\endgroup$
1
  • 1
    $\begingroup$ Related: 129875 $\endgroup$
    – lirtosiast
    Aug 2, 2019 at 7:35

1 Answer 1

7
$\begingroup$

Your G is called IntegerExponent[] in Mathematica:

Table[IntegerExponent[5^2 7^3 11^4, k], {k, {5, 7, 11}}]
   {2, 3, 4}

You should now be able to use that function to write your function F.

$\endgroup$
1
  • $\begingroup$ Thank you J.M.! $\endgroup$
    – dharmatech
    Aug 2, 2019 at 16:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.