prime_division(value, generator= Prime::Generator23.new)
Instance Public methods
Returns the factorization of value
.
Parameters
- value
-
An arbitrary integer.
-
generator
-
Optional. A pseudo-prime generator.
generator
.succ must return the next pseudo-prime number in the ascendent order. It must generate all prime numbers, but may generate non prime numbers.
Exceptions
-
ZeroDivisionError
-
when
value
is zero.
Example
For an arbitrary integer:
n = p_1**e_1 * p_2**e_2 * .... * p_n**e_n,
#prime_division(n) returns:
[[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]]. Prime.prime_division(12) #=> [[2,2], [3,1]]
Please login to continue.