Sha256: 31175e16925b03692b7a97a2ee26d229b102361dead8888510646add2e4dd281

Contents?: true

Size: 232 Bytes

Versions: 4

Compression:

Stored size: 232 Bytes

Contents

class Integer
  def catalan
    (2*self).factorial / (succ.factorial * factorial)
  end

  def catalan?
    n = -1
    loop do
      return true if (cat = (n += 1).catalan) == self
      return false if cat > self
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
numb-0.152.0 lib/numb/catalan.rb
numb-0.138.0 lib/numb/catalan.rb
numb-0.125.0 lib/numb/catalan.rb
numb-0.114.0 lib/numb/catalan.rb