factory-0.2.1.1: Rational arithmetic in an irrational world.

Safe HaskellNone
LanguageHaskell98

Factory.Math.Implementations.Factorial

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION

Synopsis

Types

Data-types

data Algorithm Source

The algorithms by which factorial has been implemented.

Constructors

Bisection

The integers from which the factorial is composed, are multiplied using Data.Interval.product'.

PrimeFactorisation

The prime factors of the factorial are extracted, then raised to the appropriate power, before multiplication.

Functions

primeFactors Source

Arguments

:: Integral base 
=> base

The number, whose factorial is to be factorised.

-> Factors base base

The base and exponent of each prime factor in the factorial, ordered by increasing base (and decreasing exponent).

  • Returns the prime factors, of the factorial of the specifed integer.
  • Precisely all the primes less than or equal to the specified integer n, are included in n!; only the multiplicity of each of these known prime components need be determined.
  • http://en.wikipedia.org/wiki/Factorial#Number_theory.
  • CAVEAT: currently a hotspot.

risingFactorial Source

Arguments

:: (Integral i, Show i) 
=> i

The lower bound of the integer-range, whose product is returned.

-> i

The number of integers in the range above.

-> i

The result.

fallingFactorial Source

Arguments

:: (Integral i, Show i) 
=> i

The upper bound of the integer-range, whose product is returned.

-> i

The number of integers in the range beneath.

-> i

The result.

Operators

(!/!) infixl 7 Source

Arguments

:: (Integral i, Fractional f, Show i) 
=> i

The numerator.

-> i

The denominator.

-> f

The resulting fraction.

  • Returns the ratio of two factorials.
  • It is more efficient than evaluating both factorials, and then dividing.
  • For more complex combinations of factorials, such as in the Binomial coefficient, extract the prime factors using primeFactors then manipulate them using the module Data.PrimeFactors, and evaluate it using by Data.PrimeFactors.product'.