Sha256: 5fb3be9068c8b6e08759c84d2fe2915147f606ec7ae1d7e99862872e42bc5f34

Contents?: true

Size: 616 Bytes

Versions: 1

Compression:

Stored size: 616 Bytes

Contents

# coding: utf-8
class Integer
  def superabundant?
    return true if self == 1
    # Constraints due to "Abundant Numbers and the Riemann Hypothesis",
    # Briggs, 2006, Experimental Mathematics, vol. 15, no. 2
    ex = primaries.map(&:last)
    return false unless [ex.last, ex.first] == ex.minmax
    primaries[1..-1].all? do |b, e|
      (e - (ex[0] * Math.log(b, primaries[0][0])).floor <= 1) and e < 2**(ex[0] + 2)
    end or return false
    return false unless [4, 36].include?(self) or ex.last == 1
    1.upto(self - 1).all? do |m|
      m.abundancy < abundancy
    end
  end
  memoize :superabundant?
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
numb-0.152.0 lib/numb/superabundant.rb