ReducePrime {primefactr} | R Documentation |
Get the Prime Factorization.
Description
Get the Prime Factorization for a number with a particular coding.
Usage
ReducePrime(code, out.summary = FALSE, primes.div = NULL)
Arguments
code |
A vector representing a number. See details. |
out.summary |
Is the result to be summarized? For example,
(2, 3, 0, 0, 1) can be summarized as (2, 5; 3, 1). Default is |
primes.div |
The vector of all prime numbers
up to |
Details
A code
is the coding of a number as follows,
number = \prod i^{code[i]},
or, which is equivalent,
\log(number) = \sum code[i] * \log(i).
For example,
5 is coded as (0, 0, 0, 0, 1),
5! is coded as (1, 1, 1, 1, 1),
8! is coded as (1, 1, 1, 1, 1, 1, 1, 1),
8! / 5! is therefore coded as (0, 0, 0, 0, 0, 1, 1, 1),
5! = 5 * 3 * 2^3 can be reduced to (0, 3, 1, 0, 1).
Note that the first element of a code
has no effect.
Value
Two rows representing prime numbers
Examples
code100 <- c(rep(0, 99), 1)
ReducePrime(c(rep(0, 99), 1), out.summary = TRUE)
primes.div <- AllPrimesUpTo(floor(sqrt(length(code100))))
ReducePrime(c(rep(0, 99), 1), primes.div = primes.div)