Sha256: ae1da106cd39cf2a218d6bb8dcfcddb47db3e538d30de2a96845d6636a166ffc
Contents?: true
Size: 313 Bytes
Versions: 16
Compression:
Stored size: 313 Bytes
Contents
# coding: utf-8 class Integer def happy? return false unless positive? n = self sad = '4 16 37 58 89 145 42 20' seq = "" loop do n = n.digits.map{|d| d ** 2}.reduce(:+) seq << n.to_s << ' ' return true if n == 1 return false if seq.include? sad end end end
Version data entries
16 entries across 16 versions & 1 rubygems