factors | R Documentation |
Performs prime factorization.
factors(n)
n |
numeric scalar specifying composite number to be factored |
Computes the prime factors of n
in ascending order, each one as often
as its multiplicity requires, such that n == prod(factors(n))
.
Returns vector containing the prime factors of n
.
The corresponding MATLAB function is called 'factor', but was renamed here to avoid conflict with R's compound object class.
H. Borchers hwborchers@googlemail.com, P. Roebuck proebuck1701@gmail.com
isprime
,
primes
factors(1002001) # 7 7 11 11 13 13
factors(65537) # is prime
## Euler's calculation
factors(2^32 + 1) # 641 6700417
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.