ReducePrime: Get the Prime Factorization.

Description Usage Arguments Details Value Examples

Description

Get the Prime Factorization for a number with a particular coding.

Usage

1
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 FALSE.

primes.div

The vector of all prime numbers up to sqrt(length(code)). Default get them for you.

Details

A code is the coding of a number as follows,

number = ∏ i^{code[i]},

or, which is equivalent,

\log(number) = ∑ code[i] * \log(i).

For example,

Note that the first element of a code has no effect.

Value

Two rows representing prime numbers

Examples

1
2
3
4
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)

privefl/primefactr documentation built on May 26, 2019, 8:32 a.m.