rewind

rewind() Instance Public methods

succ

succ() Instance Public methods Also aliased as: next

instance

instance() Class Public methods Returns the default instance of Prime.

new

new() Class Public methods obsolete. Use Prime::instance or class methods of Prime.

each

each(ubound = nil, generator = EratosthenesGenerator.new, &block) Instance Public methods Iterates the given block over all prime numbers. Parameters ubound Optional. An arbitrary positive number. The upper bound of enumeration. The method enumerates prime numbers infinitely if ubound is nil. generator Optional. An implementation of pseudo-prime generator. Return value An evaluated value of the given block at the last time. Or an enumerator which is compatible to an En

int_from_prime_division

int_from_prime_division(pd) Instance Public methods Re-composes a prime factorization and returns the product. Parameters pd Array of pairs of integers. The each internal pair consists of a prime number â a prime factor â and a natural number â an exponent. Example For [[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]], it returns: p_1**e_1 * p_2**e_2 * .... * p_n**e_n. Prime.int_from_prime_division([[2,2], [3,1]]) #=> 12

prime?

prime?(value, generator = Prime::Generator23.new) Instance Public methods Returns true if value is prime, false for a composite. Parameters value an arbitrary integer to be checked. generator optional. A pseudo-prime generator.

prime_division

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

new

Proc.new {|...| block } â a_procProc.new â a_proc Class Public methods Creates a new Proc object, bound to the current context. Proc::new may be called without a block only within a method with an attached block, in which case that block is converted to the Proc object. def proc_from Proc.new end proc = proc_from { "hello" } proc.call #=> "hello"

===

proc === obj â result_of_proc Instance Public methods Invokes the block with obj as the proc's parameter like #call. It is to allow a proc object to be a target of when clause in a case statement.