Project

General

Profile

Bug #13492 ยป 0001-prime-upper-limit.patch

stomar (Marcus Stollsteimer), 04/21/2017 07:08 PM

View differences:

lib/prime.rb
35 35
    return self >= 2 if self <= 3
36 36
    return true if self == 5
37 37
    return false unless 30.gcd(self) == 1
38
    (7..Math.sqrt(self).to_i).step(30) do |p|
38
    (7..Integer.sqrt(self)).step(30) do |p|
39 39
      return false if
40 40
        self%(p)    == 0 || self%(p+4)  == 0 || self%(p+6)  == 0 || self%(p+10) == 0 ||
41 41
        self%(p+12) == 0 || self%(p+16) == 0 || self%(p+22) == 0 || self%(p+24) == 0
......
445 445

  
446 446
      segment_min = @max_checked
447 447
      segment_max = [segment_min + max_segment_size, max_cached_prime * 2].min
448
      root = Integer(Math.sqrt(segment_max).floor)
448
      root = Integer.sqrt(segment_max)
449 449

  
450 450
      segment = ((segment_min + 1) .. segment_max).step(2).to_a
451 451