mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/matrix.rb: Styling
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d2487ed475
commit
2c686723fe
1 changed files with 6 additions and 6 deletions
12
lib/prime.rb
12
lib/prime.rb
|
@ -138,7 +138,7 @@ class Prime
|
||||||
# +generator+:: optional. A pseudo-prime generator.
|
# +generator+:: optional. A pseudo-prime generator.
|
||||||
def prime?(value, generator = Prime::Generator23.new)
|
def prime?(value, generator = Prime::Generator23.new)
|
||||||
return false if value < 2
|
return false if value < 2
|
||||||
for num in generator
|
generator.each do |num|
|
||||||
q,r = value.divmod num
|
q,r = value.divmod num
|
||||||
return true if q < num
|
return true if q < num
|
||||||
return false if r == 0
|
return false if r == 0
|
||||||
|
@ -196,7 +196,7 @@ class Prime
|
||||||
else
|
else
|
||||||
pv = []
|
pv = []
|
||||||
end
|
end
|
||||||
for prime in generator
|
generator.each do |prime|
|
||||||
count = 0
|
count = 0
|
||||||
while (value1, mod = value.divmod(prime)
|
while (value1, mod = value.divmod(prime)
|
||||||
mod) == 0
|
mod) == 0
|
||||||
|
@ -211,7 +211,7 @@ class Prime
|
||||||
if value > 1
|
if value > 1
|
||||||
pv.push [value, 1]
|
pv.push [value, 1]
|
||||||
end
|
end
|
||||||
return pv
|
pv
|
||||||
end
|
end
|
||||||
|
|
||||||
# An abstract class for enumerating pseudo-prime numbers.
|
# An abstract class for enumerating pseudo-prime numbers.
|
||||||
|
@ -340,7 +340,7 @@ class Prime
|
||||||
when 3; @prime = 5; @step = 2
|
when 3; @prime = 5; @step = 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return @prime
|
@prime
|
||||||
end
|
end
|
||||||
alias next succ
|
alias next succ
|
||||||
def rewind
|
def rewind
|
||||||
|
@ -367,7 +367,7 @@ class Prime
|
||||||
|
|
||||||
# Returns the cached prime numbers.
|
# Returns the cached prime numbers.
|
||||||
def cache
|
def cache
|
||||||
return @primes
|
@primes
|
||||||
end
|
end
|
||||||
alias primes cache
|
alias primes cache
|
||||||
alias primes_so_far cache
|
alias primes_so_far cache
|
||||||
|
@ -392,7 +392,7 @@ class Prime
|
||||||
@primes.push @next_to_check if @primes[2..@ulticheck_index].find {|prime| @next_to_check % prime == 0 }.nil?
|
@primes.push @next_to_check if @primes[2..@ulticheck_index].find {|prime| @next_to_check % prime == 0 }.nil?
|
||||||
@next_to_check += 2
|
@next_to_check += 2
|
||||||
end
|
end
|
||||||
return @primes[index]
|
@primes[index]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue