Bug #13492 ยป 0001-prime-upper-limit.patch
lib/prime.rb | ||
---|---|---|
return self >= 2 if self <= 3
|
||
return true if self == 5
|
||
return false unless 30.gcd(self) == 1
|
||
(7..Math.sqrt(self).to_i).step(30) do |p|
|
||
(7..Integer.sqrt(self)).step(30) do |p|
|
||
return false if
|
||
self%(p) == 0 || self%(p+4) == 0 || self%(p+6) == 0 || self%(p+10) == 0 ||
|
||
self%(p+12) == 0 || self%(p+16) == 0 || self%(p+22) == 0 || self%(p+24) == 0
|
||
... | ... | |
segment_min = @max_checked
|
||
segment_max = [segment_min + max_segment_size, max_cached_prime * 2].min
|
||
root = Integer(Math.sqrt(segment_max).floor)
|
||
root = Integer.sqrt(segment_max)
|
||
segment = ((segment_min + 1) .. segment_max).step(2).to_a
|
||