Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
xt_factorial(3)		   Library Functions Manual	       xt_factorial(3)

NAME
       xt_factorial() -	Fast factorial function

LIBRARY
       #include	<inttypes.h>
       #include	<xtend/math.h>
       -lxtend

SYNOPSIS
       uint64_t	   xt_factorial(unsigned n)

ARGUMENTS
       n   Integer in the range	[0,20] (inclusive) for which n!	is returned.

DESCRIPTION
       Instantaneous factorial for n in	[0,20] using a lookup table.

       Note that 21! is	beyond the range of uint64_t, so programs that need it
       should  either use a multiple precision library or rearrange the	compu-
       tations	to  avoid  repeated  multiplication   leading	to   overflow.
       xt_n_choose_k(3)	uses the latter	approach to avoid computing whole fac-
       torials before finally dividing.

RETURN VALUES
       n! if n is an element of	[0,20],	0 otherwise

EXAMPLES
       #include	<inttypes.h>
       #include	<xtend/math.h>

       printf("20! = %"	PRIu64 "n", factorial(20));

FILES
       Environment

SEE ALSO
							       xt_factorial(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=xt_factorial&sektion=3&manpath=FreeBSD+Ports+14.3.quarterly>

home | help