factorize: Prime Factors

primeFactorsR Documentation

Prime Factors

Description

primeFactors computes a vector containing the prime factors of n. radical returns the product of those unique prime factors.

Usage

  primeFactors(n)
  radical(n)

Arguments

n

nonnegative integer

Details

Computes the prime factors of n in ascending order, each one as often as its multiplicity requires, such that n == prod(primeFactors(n)).

## radical() is used in the abc-conjecture:

# abc-triple: 1 <= a < b, a, b coprime, c = a + b

# for every e > 0 there are only finitely many abc-triples with

# c > radical(a*b*c)^(1+e)

Value

Vector containing the prime factors of n, resp. the product of unique prime factors.

See Also

divisors, gmp::factorize

Examples

  primeFactors(1002001)         # 7  7  11  11  13  13
  primeFactors(65537)           # is prime
  # Euler's calculation
  primeFactors(2^32 + 1)        # 641  6700417

  radical(1002001)              # 1001

## Not run: 
  for (i in 1:99) {
    for (j in (i+1):100) {
      if (coprime(i, j)) {
        k = i + j
        r = radical(i*j*k)
        q = log(k) / log(r)  # 'quality' of the triple
        if (q > 1)
          cat(q, ":\t", i, ",", j, ",", k, "\n")
        }
      }
    }
## End(Not run)

numbers documentation built on Nov. 23, 2022, 9:06 a.m.