From 287a34ae0dfc23e4158f67cb7783d239f202c368 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 6 Mar 2009 03:56:38 +0000 Subject: * {ext,lib,test}/**/*.rb: removed trailing spaces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/prime.rb | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'lib/prime.rb') diff --git a/lib/prime.rb b/lib/prime.rb index ce71d5e00f..ec3f8fa8cb 100644 --- a/lib/prime.rb +++ b/lib/prime.rb @@ -21,9 +21,9 @@ class Integer def Integer.from_prime_division(pd) Prime.int_from_prime_division(pd) end - + # Returns the factorization of +self+. - # + # # See Prime#prime_division for more details. def prime_division(generator = Prime::Generator23.new) Prime.prime_division(self, generator) @@ -34,7 +34,7 @@ class Integer Prime.prime?(self) end - # Iterates the given block over all prime numbers. + # Iterates the given block over all prime numbers. # # See +Prime+#each for more details. def Integer.each_prime(ubound, &block) # :yields: prime @@ -51,11 +51,11 @@ end # end # # == Retrieving the instance -# +Prime+.new is obsolete. Now +Prime+ has the default instance and you can +# +Prime+.new is obsolete. Now +Prime+ has the default instance and you can # access it as +Prime+.instance. # # For convenience, each instance method of +Prime+.instance can be accessed -# as a class method of +Prime+. +# as a class method of +Prime+. # # e.g. # Prime.instance.prime?(2) #=> true @@ -64,19 +64,19 @@ end # == Generators # A "generator" provides an implementation of enumerating pseudo-prime # numbers and it remembers the position of enumeration and upper bound. -# Futhermore, it is a external iterator of prime enumeration which is +# Futhermore, it is a external iterator of prime enumeration which is # compatible to an Enumerator. # # +Prime+::+PseudoPrimeGenerator+ is the base class for generators. # There are few implementations of generator. # # [+Prime+::+EratosthenesGenerator+] -# Uses eratosthenes's sieve. +# Uses eratosthenes's sieve. # [+Prime+::+TrialDivisionGenerator+] # Uses the trial division method. # [+Prime+::+Generator23+] # Generates all positive integers which is not divided by 2 nor 3. -# This sequence is very bad as a pseudo-prime sequence. But this +# This sequence is very bad as a pseudo-prime sequence. But this # is faster and uses much less memory than other generators. So, # it is suitable for factorizing an integer which is not large but # has many prime factors. e.g. for Prime#prime? . @@ -106,23 +106,23 @@ class Prime # # == Parameters # +ubound+:: - # Optional. An arbitrary positive number. + # Optional. An arbitrary positive number. # The upper bound of enumeration. The method enumerates - # prime numbers infinitely if +ubound+ is nil. + # 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 +Enumerator+ - # if no block given. + # if no block given. # # == Description # Calls +block+ once for each prime numer, passing the prime as # a parameter. # # +ubound+:: - # Upper bound of prime numbers. The iterator stops after + # Upper bound of prime numbers. The iterator stops after # yields all prime numbers p <= +ubound+. # # == Note @@ -156,9 +156,9 @@ class Prime # Re-composes a prime factorization and returns the product. # # == Parameters - # +pd+:: Array of pairs of integers. The each internal + # +pd+:: Array of pairs of integers. The each internal # pair consists of a prime number -- a prime factor -- - # and a natural number -- an exponent. + # and a natural number -- an exponent. # # == Example # For [[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]], it returns @@ -176,7 +176,7 @@ class Prime # == Parameters # +value+:: An arbitrary integer. # +generator+:: Optional. A pseudo-prime generator. - # +generator+.succ must return the next + # +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. @@ -185,7 +185,7 @@ class Prime # +ZeroDivisionError+:: when +value+ is zero. # # == Example - # For an arbitrary integer + # 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]]. @@ -231,9 +231,9 @@ class Prime end # returns the next pseudo-prime number, and move the internal - # position forward. + # position forward. # - # +PseudoPrimeGenerator+#succ raises +NotImplementedError+. + # +PseudoPrimeGenerator+#succ raises +NotImplementedError+. def succ raise NotImplementedError, "need to define `succ'" end @@ -278,7 +278,7 @@ class Prime end end end - + # An implementation of +PseudoPrimeGenerator+. # # Uses +EratosthenesSieve+. @@ -286,7 +286,7 @@ class Prime def initialize @last_prime = nil end - + def succ @last_prime = @last_prime ? EratosthenesSieve.instance.next_to(@last_prime) : 2 end @@ -296,13 +296,13 @@ class Prime alias next succ end - # An implementation of +PseudoPrimeGenerator+ which uses + # An implementation of +PseudoPrimeGenerator+ which uses # a prime table generated by trial division. class TrialDivisionGenerator