Class: Fortune::C
- Inherits:
-
P_abstract
- Object
- P_abstract
- Fortune::C
- Defined in:
- lib/fortune/c.rb
Overview
Combinations without repetition example: 10 different elements (students) and you need select 5 of them (how many ways of selection exists?)
elements does not ordered ([a,b,c] == [b,c,a])
C.calc(:elements => 10, :select => 5)
Instance Attribute Summary
Attributes inherited from P_abstract
Instance Method Summary collapse
-
#initialize(h) ⇒ C
constructor
A new instance of C.
Methods inherited from P_abstract
Constructor Details
#initialize(h) ⇒ C
Returns a new instance of C.
8 9 10 11 |
# File 'lib/fortune/c.rb', line 8 def initialize(h) super(h) self.value = Math.factorial(self.n)/(Math.factorial(self.k)*Math.factorial(self.n - self.k)) end |