Evaluate the Factorial function of a single-precision floating-point number.
The factorial function may be defined as the product
or according to the recurrence relation
Following the convention for an empty product, in all definitions,
The Gamma function extends the factorial function for non-integer values.
The factorial of a negative integer is not defined.
var factorialf = require( '@stdlib/math/base/special/factorialf' );Evaluates the factorial function of a single-precision floating-point number.
var v = factorialf( 3.0 );
// returns 6.0
v = factorialf( -1.5 );
// returns ~-3.545
v = factorialf( -0.5 );
// returns ~1.772
v = factorialf( 0.5 );
// returns ~0.886
v = factorialf( -10.0 );
// returns NaN
v = factorialf( 34.0 );
// returns ~2.952e38
v = factorialf( 35.0 );
// returns Infinity
v = factorialf( NaN );
// returns NaNvar incrspace = require( '@stdlib/array/base/incrspace' );
var factorialf = require( '@stdlib/math/base/special/factorialf' );
var x = incrspace( -10.0, 50.0, 1.0 );
var i;
for ( i = 0; i < x.length; i++ ) {
console.log( 'x: %d, f(x): %d', x[ i ], factorialf( x[ i ] ) );
}#include "stdlib/math/base/special/factorialf.h"Evaluates the factorial function of a single-precision floating-point number.
float out = stdlib_base_factorialf( 3.0f );
// returns 6.0f
out = stdlib_base_factorialf( -1.5f );
// returns ~-3.545fThe function accepts the following arguments:
- x:
[in] floatinput value.
float stdlib_base_factorialf( const float x );#include "stdlib/math/base/special/factorialf.h"
#include <stdio.h>
int main( void ) {
const float x[] = { 2.0f, 3.0f, 5.0f, 8.0f };
float y;
int i;
for ( i = 0; i < 4; i++ ) {
y = stdlib_base_factorialf( x[ i ] );
printf( "factorialf(%f) = %f\n", x[ i ], y );
}
}@stdlib/math/base/special/factorial: evaluate the factorial function.@stdlib/math/base/special/factoriallnf: evaluate the natural logarithm of the factorial function of a single-precision floating-point number.