Usage :
r = subfactorial(n) calculates the subfactorial of a non -negative integer (n) using the inclusion-exclusion principle.
The subfactorial can be written as,
!n = n! sum( (-1)^k / k! ), for k = 0 to n
!n : subfactorial(n)
n! : factorial(n) = 1*2*3*...*n
Remark :
This function is limited by largest floating point number that can be
defined, as given by the realmax. Since,
subfactorial(170) < realmax < subfactorial(171)
Maximum value of input (n) cannot exceed 170.
Higher value of (n) will return NaN.
Example:
a = subfactorial(12);
returns -> a = 176214841
See Also:
factorial
인용 양식
Yash (2026). Subfactorial (https://kr.mathworks.com/matlabcentral/fileexchange/24566-subfactorial), MATLAB Central File Exchange. 검색 날짜: .
MATLAB 릴리스 호환 정보
플랫폼 호환성
Windows macOS Linux카테고리
태그
| 버전 | 게시됨 | 릴리스 정보 | |
|---|---|---|---|
| 1.0.0.0 |
