method
prime_division
v1_9_3_125 -
Show latest stable
-
0 notes -
Class: Prime
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (-8)
- 1_9_3_125 (38)
- 1_9_3_392 (0)
- 2_1_10 (34)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
prime_division(value, generator= Prime::Generator23.new)
public
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
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]]