1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica: How do I program this? Square free part of an integer

  1. Jul 8, 2010 #1
    I am attempting to program Mathematica to multiply the square free terms of an integer. Basically say we are looking at 252, its prime factors are 2^2*3^2*7. So what I want to do is have Mathematica return to me just 2*3*7 when I enter 252.

    So I have this

    S := FactorInteger[252]
    Transpose[[1]]

    which returns

    {{2, 2}, {3, 2}, {7, 1}}
    {2, 3, 7}

    So, knowing a way to have Mathematica multiply 2*3*7 will give me what I need. Thanks!
     
  2. jcsd
  3. Jul 8, 2010 #2

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Times @@ {a, b, c, d, ...} I think is the clever way to do it. I'm pretty sure there is a Product function you could make use of, and in a pinch, you could always write a Function or Module yourself that uses Do to create a loop.
     
  4. Jul 8, 2010 #3

    vela

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor

    Use the Apply operator, @@. Times@@{a,b,c} will return the product of a, b, and c.
     
  5. Jul 9, 2010 #4
    Thank you very much!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Mathematica: How do I program this? Square free part of an integer
  1. How do I do this? (Replies: 20)

Loading...