Sha256: 39fb826c7b889f52be9d3842456a9e5a5aa6655f7734259a2f3bbd03c5d01268

Contents?: true

Size: 253 Bytes

Versions: 2

Compression:

Stored size: 253 Bytes

Contents

class Integer
  def palindrome?
    to_s.reverse.to_i == self
  end

  def lychrel?
    n = self
    # This limit is as arbitrary as it looks
    100.times do
      return false if n.palindrome?
      n += n.to_s.reverse.to_i
    end
    true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
numb-0.111.0 lib/numb/lychrel.rb
numb-0.109.0 lib/numb/lychrel.rb