Sha256: 318ba8615071a42537c8e54684faae5d2cad25179af49d30e3c2723e11dd396b

Contents?: true

Size: 163 Bytes

Versions: 7

Compression:

Stored size: 163 Bytes

Contents

# coding: utf-8
class Integer
  def choose(k)
    k > self ? 0 : factorial / (k.factorial * (self - k).factorial)
  end

  alias :binomial_coefficient :choose
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
numb-0.186.0 lib/numb/choose.rb
numb-0.185.0 lib/numb/choose.rb
numb-0.184.0 lib/numb/choose.rb
numb-0.181.0 lib/numb/choose.rb
numb-0.170.0 lib/numb/choose.rb
numb-0.152.0 lib/numb/choose.rb
numb-0.138.0 lib/numb/choose.rb