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

Click For Summary

Homework Help Overview

The discussion revolves around programming in Mathematica to compute the square-free part of an integer, specifically using the example of the integer 252 and its prime factorization.

Discussion Character

  • Exploratory, Mathematical reasoning

Approaches and Questions Raised

  • Participants discuss methods to extract and multiply the square-free components of an integer's prime factorization. The original poster shares their initial approach using FactorInteger and transposing the result. Others suggest using the Times function and the Apply operator to achieve the desired multiplication.

Discussion Status

Several participants have contributed ideas on how to multiply the square-free factors, with suggestions including the use of Times and Apply. The conversation appears to be progressing with various methods being explored, though no consensus has been reached on a single approach.

Contextual Notes

The original poster is seeking a specific programming solution within Mathematica, indicating a focus on practical implementation rather than theoretical discussion.

ABarrios
Messages
23
Reaction score
0
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!
 
Physics news on Phys.org
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.
 
Use the Apply operator, @@. Times@@{a,b,c} will return the product of a, b, and c.
 
Thank you very much!
 

Similar threads

  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
18
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 13 ·
Replies
13
Views
1K
Replies
9
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K