Learn R Programming

utilities (version 0.4.0)

PFD: Prime Factor Decomposition (PFD)

Description

PFD converts a positive integer to its prime-factor decomposition or *vice versa*

Usage

PFD(x)

# S3 method for prime.factor.decomposition print(x, quote = FALSE, ...)

Arguments

x

An input vector/matrix/array (can be a vector of integers/bigz or PFDs)

quote

logical, indicating whether or not strings should be printed with surrounding quotes.

...

further arguments passed to or from other methods.

Value

If the input is integer/bigz then the output is the PFD; if the input is PFD then the output is integer/bigz

Details

This function converts a vector of integers to a corresponding character vector giving the prime-factor decomposition in a condensed form. The input can be a vector of integers or a 'bigz' vector containing large integers. In either case the function returns the corresponding vector of the prime-factor decomposition (PFD) values, written in a condensed character form. The function also converts back from the PFD form to an integer/bigz vector.

This function depends on the gmp package.

Examples

Run this code
# NOT RUN {
PFD(1:10)
stopifnot(all.equal(1:100, PFD(PFD(1:100))))
# }

Run the code above in your browser using DataLab