fact

From DavinciWiki
(Difference between revisions)
Jump to: navigation, search
m (Added factor, intprod, and product to list of related functions; factor is not really related, but I included it for convenience, in case someone confuses fact and factor)
m (Reorganized description)
 
Line 4: Line 4:
 
   
 
   
 
Return Value: The factorial of the input
 
Return Value: The factorial of the input
 +
|
 +
[[Syntax]]: fact(x)
 +
 +
'x' - a numeric array whose value is an integer or half-integer x, such that -0.5 ≤ x ≤ 34
  
 
fact(n) = n! = n*(n-1)*(n-2)*...*2*1 for integers; 0! = 1
 
fact(n) = n! = n*(n-1)*(n-2)*...*2*1 for integers; 0! = 1
Line 20: Line 24:
  
 
If no arguments are input, fact() prints its description, as shown below.
 
If no arguments are input, fact() prints its description, as shown below.
|
 
[[Syntax]]: fact(x)
 
 
'x' - a numeric array whose value is an integer or half-integer x, such that -0.5 ≤ x ≤ 34
 
 
|
 
|
 
  dv> fact()
 
  dv> fact()

Latest revision as of 16:47, 18 November 2009


Description

Factorial.

Arguments and Return Values

Arguments: One numeric array

Return Value: The factorial of the input

Usage

Syntax: fact(x)

'x' - a numeric array whose value is an integer or half-integer x, such that -0.5 ≤ x ≤ 34

fact(n) = n! = n*(n-1)*(n-2)*...*2*1 for integers; 0! = 1

n! = n*(n-1)*(n-2)*...0.5*fact(-0.5) for half-integers; (-0.5)! = √π

Return format:

int, when all elements of input are integers less than or equal to 12 (any format)

float, when some elements of input are half-integer floats, or when the maximum value of the input is greater than 12

double, when some elements of input are half-integer doubles

In general, the function returns the simplest format that can accurately represent the value of the factorial.

If no arguments are input, fact() prints its description, as shown below.

Examples

dv> fact()

Factorial
fact(n), integers or half-integers -0.5 <= n <= 34
Works for arrays
S.Marshall 02-17-2008

0
dv> fact(create(7))
7x1x1 array of int, bsq format [28 bytes]
1       1       2       6       24      120     720
dv> fact(-0.5//0.//0.5//1.//1.5//2.)
6x1x1 array of float, bsq format [24 bytes]
1.77245 1.00000 0.886227        1.00000 1.32934 2.00000
dv> fact(-1)

Input must be integers or half-integers -0.5 <= n <= 34

0
dv> fact(33)
8.68332e+36
dv> fact(34)
2.95233e+38
dv> fact(35)

Input must be integers or half-integers -0.5 <= n <= 34

0

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Major Sub-Functions

Related Functions

Recent Library Changes

Created On: 12-07-2007
Modified On: 11-18-2009

Personal tools