Class: Fortune::Pn

Inherits:
P_abstract show all
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

#k, #n, #value

Instance Method Summary collapse

Methods inherited from P_abstract

calc

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