Class: Fortune::Pn
- Inherits:
-
P_abstract
- Object
- P_abstract
- Fortune::Pn
- Defined in:
- lib/fortune/pn.rb
Overview
Permutation without repetition example: the amount of distributions of the four teams in four places (Pn.calc(4))
Pn.calc(5), Pn.calc(:elements => 5), Pn.calc(:elements => 5, :select => 2)
Instance Attribute Summary
Attributes inherited from P_abstract
Instance Method Summary collapse
-
#initialize(h) ⇒ Pn
constructor
A new instance of Pn.
Methods inherited from P_abstract
Constructor Details
#initialize(h) ⇒ Pn
Returns a new instance of Pn.
8 9 10 11 12 |
# File 'lib/fortune/pn.rb', line 8 def initialize(h) h = {:n => h} unless h.is_a?(Hash) super(h) self.value = self.k ? A.calc(h) : Math.factorial(self.n) end |