Sha256: d500b552caa660e3b82149d7fd745322ade14db1c56426bff6196d895c8ee2f0

Contents?: true

Size: 325 Bytes

Versions: 5

Compression:

Stored size: 325 Bytes

Contents

class Integer
  def bell?
    triangle = [[1]]
    r = 1
    loop do
      row = [triangle[r - 1][r - 1]]
      (1..r).each do |c|
        row << triangle[r - 1][c - 1] + row[c - 1]
      end
      triangle[r] = row
      return false if row.first > self
      return true if row.first == self
      r += 1
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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