@stdlib/math-base-special-lucasf
v0.1.1
Published
Compute the nth Lucas number as a single-precision floating-point number.
Readme
lucasf
Compute the nth Lucas number as a single-precision floating-point number.
The Lucas numbers are the integer sequence
The sequence is defined by the recurrence relation
Installation
npm install @stdlib/math-base-special-lucasfUsage
var lucasf = require( '@stdlib/math-base-special-lucasf' );lucasf( n )
Computes the nth Lucas number as a single-precision floating-point number.
var v = lucasf( 0 );
// returns 2
v = lucasf( 1 );
// returns 1
v = lucasf( 2 );
// returns 3
v = lucasf( 3 );
// returns 4
v = lucasf( 34 );
// returns 12752043If n > 34, the function returns NaN, as larger Lucas numbers cannot be safely represented in single-precision floating-point format.
var v = lucasf( 35 );
// returns NaNIf not provided a nonnegative integer value, the function returns NaN.
var v = lucasf( 3.14 );
// returns NaN
v = lucasf( -1 );
// returns NaNIf provided NaN, the function returns NaN.
var v = lucasf( NaN );
// returns NaNExamples
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var lucasf = require( '@stdlib/math-base-special-lucasf' );
var x = discreteUniform( 10, 0, 34, {
'dtype': 'int32'
});
logEachMap( 'lucasf(%d) = %0.1f', x, lucasf );C APIs
Usage
#include "stdlib/math/base/special/lucasf.h"stdlib_base_lucasf( n )
Computes the nth Lucas number as a single-precision floating-point number.
float out = stdlib_base_lucasf( 0.0f );
// returns 2.0f
out = stdlib_base_lucasf( 1.0f );
// returns 1.0fThe function accepts the following arguments:
- n:
[in] floatinput value.
float stdlib_base_lucasf( const float n );Examples
#include "stdlib/math/base/special/lucasf.h"
#include <stdio.h>
int main( void ) {
float i;
float v;
for ( i = 0.0f; i < 35.0f; i++ ) {
v = stdlib_base_lucasf( i );
printf( "lucasf(%f) = %f\n", i, v );
}
}Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
