Class: Integer

Inherits:
Object
  • Object
show all
Defined in:
lib/prime.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.each_prime(ubound, &block) ⇒ Object

Iterates the given block over all prime numbers.

See Prime#each for more details.


40
41
42
# File 'lib/prime.rb', line 40

def Integer.each_prime(ubound, &block) # :yields: prime
  Prime.each(ubound, &block)
end

.from_prime_division(pd) ⇒ Object

Re-composes a prime factorization and returns the product.

See Prime#int_from_prime_division for more details.


21
22
23
# File 'lib/prime.rb', line 21

def Integer.from_prime_division(pd)
  Prime.int_from_prime_division(pd)
end

Instance Method Details

#prime?Boolean

Returns true if self is a prime number, else returns false.

Returns:

  • (Boolean)

33
34
35
# File 'lib/prime.rb', line 33

def prime?
  Prime.prime?(self)
end

#prime_division(generator = Prime::Generator23.new) ⇒ Object

Returns the factorization of self.

See Prime#prime_division for more details.


28
29
30
# File 'lib/prime.rb', line 28

def prime_division(generator = Prime::Generator23.new)
  Prime.prime_division(self, generator)
end