Module: Combinatorics::PowerSet
- Defined in:
- lib/combinatorics/power_set/mixin.rb,
lib/combinatorics/power_set/cardinality.rb
Defined Under Namespace
Modules: Mixin
Class Method Summary collapse
-
.cardinality(n) ⇒ Fixnum
Get number of elements in power set from number of elements in input set.
-
.P(n) ⇒ Object
Wrapper function for power set cardinality method defined above.
Class Method Details
.cardinality(n) ⇒ Fixnum
Note:
Cardinality of power set on an empty set equals factorial(0)
equals 1.
Get number of elements in power set from number of elements in input set.
24 25 26 |
# File 'lib/combinatorics/power_set/cardinality.rb', line 24 def self.cardinality(n) Math.factorial(n) end |
.P(n) ⇒ Object
Note:
The letter `P' stands for the power set function in the context of statements regarding discrete mathematics.
Wrapper function for power set cardinality method defined above
34 35 36 |
# File 'lib/combinatorics/power_set/cardinality.rb', line 34 def self.P(n) cardinality(n) end |