Skip to content

Commit

Permalink
Integer#frugal?: Document
Browse files Browse the repository at this point in the history
  • Loading branch information
runpaint committed Aug 17, 2009
1 parent 97f9ac7 commit d6ceb8d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/numb/frugal.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# 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
Expand Down

0 comments on commit d6ceb8d

Please sign in to comment.