Is there a function to eliminate repetitive factors?

217 Views Asked by At

Say I have a number, like 60. Which has a prime factorization of $$[2,2,3,5]$$ What function would take in 60 and remove redundant factors? In this case, it should return 30

Edit: I did some more research, and the term I'm wording in looking for is reducing a number to its distinct factors

2

There are 2 best solutions below

6
On BEST ANSWER

Lets define the following function:

Given $x = \prod_{i=1}^{n}p_{i}^{a_{i}}$ i.e. the prime factorisation of $x$

$f(x):= \prod_{i=1}^{n}p_{i}$

Is this what you were looking for?

3
On

In the context of ring theory, you can think of the number $n$ as the ideal $(n)$ in the ring $\mathbb{Z}$. The object you're looking for is called the radical of the ideal.