README.md (2200B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # Falling Factorial 22 23 > Compute the [falling factorial][falling-and-rising-factorials]. 24 25 <section class="intro"> 26 27 </section> 28 29 <!-- /.intro --> 30 31 <section class="usage"> 32 33 ## Usage 34 35 ```javascript 36 var fallingFactorial = require( '@stdlib/math/base/special/falling-factorial' ); 37 ``` 38 39 #### fallingFactorial( x, n ) 40 41 Evaluates the [falling factorial][falling-and-rising-factorials] of `x` and `n`. 42 43 ```javascript 44 var v = fallingFactorial( 0.9, 5 ); 45 // returns ~0.644 46 47 v = fallingFactorial( -9.0, 3 ); 48 // returns -990.0 49 50 v = fallingFactorial( 0.0, 2 ); 51 // returns 0.0 52 53 v = fallingFactorial( NaN, 3 ); 54 // returns NaN 55 56 v = fallingFactorial( 5.0, NaN ); 57 // returns NaN 58 59 v = fallingFactorial( NaN, NaN ); 60 // returns NaN 61 ``` 62 63 The function returns `NaN` if not provided a nonnegative integer for `n`. 64 65 ```javascript 66 var v = fallingFactorial( 2.0, 1.5 ); 67 // returns NaN 68 69 v = fallingFactorial( 3.0, -2 ); 70 // returns NaN 71 ``` 72 73 </section> 74 75 <!-- /.usage --> 76 77 <section class="examples"> 78 79 ## Examples 80 81 <!-- eslint no-undef: "error" --> 82 83 ```javascript 84 var randu = require( '@stdlib/random/base/randu' ); 85 var ceil = require( '@stdlib/math/base/special/ceil' ); 86 var fallingFactorial = require( '@stdlib/math/base/special/falling-factorial' ); 87 88 var n; 89 var x; 90 var i; 91 92 for ( i = 0; i < 100; i++ ) { 93 x = ( randu()*40.0 ) - 20.0; 94 n = ceil( randu()*20.0 ); 95 console.log( 'fallingFactorial(%d,%d) = %d', x, n, fallingFactorial( x, n ) ); 96 } 97 ``` 98 99 </section> 100 101 <!-- /.examples --> 102 103 <section class="links"> 104 105 [falling-and-rising-factorials]: https://en.wikipedia.org/wiki/Falling_and_rising_factorials 106 107 </section> 108 109 <!-- /.links -->