Learn R Programming

numbers (version 0.5-2)

primeFactors: Prime Factors

Description

Returns a vector containing the prime factors of n.

Usage

primeFactors(n)

Arguments

n
nonnegative integer

Value

  • Vector containing the prime factors of n.

Details

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

See Also

factorize

Examples

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

Run the code above in your browser using DataLab