Class: Integer
Class Method Summary (collapse)
-
+ (Object) each_prime(ubound, &block)
Iterates the given block over all prime numbers.
-
+ (Object) from_prime_division(pd)
Re-composes a prime factorization and returns the product.
- + (Object) yaml_new(val)
Instance Method Summary (collapse)
-
- (Boolean) prime?
Returns true if self is a prime number, false for a composite.
-
- (Object) prime_division(generator = Prime::Generator23.new)
Returns the factorization of self.
- - (Object) to_yaml(output = nil)
Class Method Details
+ (Object) each_prime(ubound, &block)
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 |
+ (Object) from_prime_division(pd)
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 |
+ (Object) yaml_new(val)
138 139 140 |
# File 'lib/yaml/rubytypes.rb', line 138 def Integer.yaml_new(val) val.to_i end |
Instance Method Details
- (Boolean) prime?
Returns true if self is a prime number, false for a composite.
33 34 35 |
# File 'lib/prime.rb', line 33 def prime? Prime.prime?(self) end |
- (Object) prime_division(generator = Prime::Generator23.new)
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 |
- (Object) to_yaml(output = nil)
142 143 144 145 146 |
# File 'lib/yaml/rubytypes.rb', line 142 def to_yaml(output = nil) YAML::quick_emit(output) do |out| out.scalar("tag:yaml.org,2002:int", self.to_s, :plain) end end |