Sha256: fece3ae770380aa44a6b8e9070c16cb9a672ea960b09f431bcf9af95ad556bab
Contents?: true
Size: 545 Bytes
Versions: 19
Compression:
Stored size: 545 Bytes
Contents
# coding: utf-8 class Integer # A Dudeney number is a positive integer that is a perfect cube such that # the sum of its decimal digits is the cube root of the number. # # Returns true if self is a Dudeney number; false otherwise. # # 4913.dudeney? #=> true # 5832.dudeney? #=> true # 98.dudeney? #=> false # def dudeney? # The ugly hack below is seemingly needed for 1.8 compatibility. I ave # yet to understand why. Math.cbrt(self).to_s.sub(/\.0$/,'') == self.digits.reduce(:+).to_s end end
Version data entries
19 entries across 19 versions & 1 rubygems