Learn R Programming

primes (version 1.6.0)

prime_factors: Perform Prime Factorization on a Vector

Description

Compute the prime factors of elements of an integer vector.

Usage

prime_factors(x)

Value

A list of integer vectors reflecting the prime factorizations of each element of the input vector.

Arguments

x

an integer vector.

Author

Paul Egeler, MS

Examples

Run this code
prime_factors(c(1, 5:7, 99))
## [[1]]
## integer(0)
##
## [[2]]
## [1] 5
##
## [[3]]
## [1] 2 3
##
## [[4]]
## [1] 7
##
## [[5]]
## [1]  3  3 11

Run the code above in your browser using DataLab