0
$\begingroup$

If I have the product of some unique numbers such as:

$9 . 6 . 8 . 10 = 4320$

(edit where each of the products must be less than or equal to a given number, 10)

If I want to find if any of the numbers is a square I would decompose as follows:

$(3\,.\,3)\,.\,(3\,.\,2)\,.\,(4\,.\,2)\,.\,(5\,\,.\,2) = 4320$

here obviously 9 is the square number but is there a function to do that in Mathematica 9?

The nearest I have found finds powers of unique primes:

$2^5 . 3^3 . 5 = 4320$

using the function:

FactorInteger[4320]
{{2, 5}, {3, 3}, {5, 1}}

Is there any general way to find if a number such as 4320 contains any square numbers in products such as 9 such that this is less than or equal to 10 and is still a product of 4 numbers in this case?

$\endgroup$
  • $\begingroup$ Does SquareFreeQ work for you? $\endgroup$ – Carl Woll Jun 17 '18 at 13:40
  • $\begingroup$ There are more squares in $4320$ beyond $9$: you also have $4=2^2$, $16=4^2$. Do you want a list of all primes squared, or also non-primes? $\endgroup$ – AccidentalFourierTransform Jun 17 '18 at 13:44
  • $\begingroup$ SquareFreeQ pulls all the squares I need just the squares present in the 4 unique numbers that make the product and yes I mean prime squares only. $\endgroup$ – onepound Jun 17 '18 at 13:47
  • 2
    $\begingroup$ First[#]^2 & /@ Select[FactorInteger[4320], #[[2]] > 1 &] ? $\endgroup$ – AccidentalFourierTransform Jun 17 '18 at 13:51
  • 1
    $\begingroup$ How about PrimePowerQ? $\endgroup$ – Carl Woll Jun 17 '18 at 13:53
1
$\begingroup$

I have had an idea based on @AccidentalFourierTransform comment.

First[#]^2 & /@ Select[FactorInteger[4320], #[[2]] > 1 &]

produces two squares in the case of 4320 '4' and '9' but only one will reconstruct 4320 with just 4 numbers less than or equal to 10.

4 would fail since since 4 is less than half of 10 therefore all squares less than 5 can be excluded since 10.9.8.4 < 4320.

Select[First[#]^2 & /@ Select[FactorInteger[4320], #[[2]] > 1 &], 5<= # <= 10 &]

and generalised replacing constants shown as convenient:

Select[First[#]^2 & /@ Select[FactorInteger[m], #[[2]] > 1 &], (n/2) <= # <= n &]
$\endgroup$

Your Answer

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

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