Computes 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
var lucasf = require( '@stdlib/math/base/special/lucasf' );
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 12752043
If 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 NaN
If not provided a nonnegative integer value, the function returns NaN
.
var v = lucasf( 3.14 );
// returns NaN
v = lucasf( -1 );
// returns NaN
If provided NaN
, the function returns NaN
.
var v = lucasf( NaN );
// returns NaN
var lucasf = require( '@stdlib/math/base/special/lucasf' );
var v;
var i;
for ( i = 0; i < 35; i++ ) {
v = lucasf( i );
console.log( v );
}
#include "stdlib/math/base/special/lucasf.h"
Computes the nth Lucas number as a single-precision floating-point number.
float out = stdlib_base_lucasf( 0 );
// returns 2.0f
out = stdlib_base_lucasf( 1 );
// returns 1.0f
The function accepts the following arguments:
- n:
[in] int32_t
input value.
float stdlib_base_lucasf( const int32_t n );
#include "stdlib/math/base/special/lucasf.h"
#include <stdio.h>
#include <stdint.h>
int main( void ) {
int32_t i;
float v;
for ( i = 0; i < 35; i++ ) {
v = stdlib_base_lucasf( i );
printf( "lucasf(%d) = %f\n", i, v );
}
}