Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

factors

MATLAB factor function


Description

Performs prime factorization.

Usage

factors(n)

Arguments

n

numeric scalar specifying composite number to be factored

Details

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

Value

Returns vector containing the prime factors of n.

Note

The corresponding MATLAB function is called 'factor', but was renamed here to avoid conflict with R's compound object class.

Author(s)

See Also

Examples

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

matlab

MATLAB emulation package

v1.0.2
Artistic-2.0
Authors
P. Roebuck
Initial release
2014-06-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.