Sha256: fa1e7991b9d7dfa4cd814291cc7e7f47c1711d6c0de2477e0236faac075380af

Contents?: true

Size: 406 Bytes

Versions: 36

Compression:

Stored size: 406 Bytes

Contents

# coding: utf-8
class Integer

  # A frugal number has more digits than the number of digits in its prime
  # factorization (including exponents).
  #
  # Returns true if self is frugal; false otherwise.
  #
  #     128.frugal?  #=> true
  #     256.frugal?  #=> true
  #     300.frugal?  #=> false
  #
  def frugal?
    digits.size > prime_division.flatten.reject{|d|d==1}.join.to_i.digits.size
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
numb-0.186.0 lib/numb/frugal.rb
numb-0.185.0 lib/numb/frugal.rb
numb-0.184.0 lib/numb/frugal.rb
numb-0.181.0 lib/numb/frugal.rb
numb-0.170.0 lib/numb/frugal.rb
numb-0.152.0 lib/numb/frugal.rb
numb-0.138.0 lib/numb/frugal.rb
numb-0.125.0 lib/numb/frugal.rb
numb-0.114.0 lib/numb/frugal.rb
numb-0.111.0 lib/numb/frugal.rb
numb-0.109.0 lib/numb/frugal.rb
numb-0.99.0 lib/numb/frugal.rb
numb-0.96.0 lib/numb/frugal.rb
numb-0.89.0 lib/numb/frugal.rb
numb-0.84.0 lib/numb/frugal.rb
numb-0.77.0 lib/numb/frugal.rb
numb-0.72.1 lib/numb/frugal.rb
numb-0.72.0 lib/numb/frugal.rb
numb-0.68.0 lib/numb/frugal.rb
numb-0.63.0 lib/numb/frugal.rb