Sha256: 1ef7fb366796b8b2f51e9fc9255192d58534b2507b0edd3c88eb187d16e89812

Contents?: true

Size: 504 Bytes

Versions: 1

Compression:

Stored size: 504 Bytes

Contents

# frozen_string_literal: true

require_relative '../extensions/math'

module Combinatorics
  module Derange
    #
    # Compute the number of derangements for a data structure of given size
    #
    # @see Math.subfactorial
    #
    def self.cardinality(n)
      Math.subfactorial(n)
    end

    #
    # Wrapper for derangement cardinality method defined above
    #
    # @note The letter `D' is academic representation for derangements
    #
    def self.D(n)
      cardinality(n)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
combinatorics-0.5.0 lib/combinatorics/derange/cardinality.rb