Sha256: 7e2d41b23d970561f612abedccb05498e3caa09ef914882ec9451278ab44c5c7

Contents?: true

Size: 514 Bytes

Versions: 11

Compression:

Stored size: 514 Bytes

Contents

# coding: utf-8
class Integer
  # A deficient number is a number n for which σ(n) < 2n. That is, the sum of
  # its divisors are less than the number. (To calculate the sum of divisors
  # for an arbitrary integer see Integer#σ).
  #
  # Returns true if the number is deficient; false otherwise.
  #
  #     8.deficient?  #=> true
  #     27.deficient? #=> true
  #     6.deficient?  #=> false
  #
  def deficient?
    return false unless positive?
    σ < (2 * self)
  end

  alias :defective? :deficient?
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
numb-0.152.0 lib/numb/deficient.rb
numb-0.138.0 lib/numb/deficient.rb
numb-0.125.0 lib/numb/deficient.rb
numb-0.114.0 lib/numb/deficient.rb
numb-0.111.0 lib/numb/deficient.rb
numb-0.109.0 lib/numb/deficient.rb
numb-0.99.0 lib/numb/deficient.rb
numb-0.96.0 lib/numb/deficient.rb
numb-0.89.0 lib/numb/deficient.rb
numb-0.84.0 lib/numb/deficient.rb
numb-0.77.0 lib/numb/deficient.rb