Non-Fibonacci
Compute the nth non-Fibonacci single-precision floating-point number.
The nth non-Fibonacci number is given by
where φ
is the golden ratio.
Usage
var nonfibonaccif = require( '@stdlib/math/base/special/nonfibonaccif' );
nonfibonaccif( n )
Computes the nth non-Fibonacci single-precision floating-point number.
var v = nonfibonaccif( 1 );
// returns 4
v = nonfibonaccif( 2 );
// returns 6
v = nonfibonaccif( 3 );
// returns 7
If provided either a non-integer or n < 1
, the function returns NaN
.
var v = nonfibonaccif( -1 );
// returns NaN
v = nonfibonaccif( 3.14 );
// returns NaN
If provided NaN
, the function returns NaN
.
var v = nonfibonaccif( NaN );
// returns NaN
Examples
var nonfibonaccif = require( '@stdlib/math/base/special/nonfibonaccif' );
var i;
for ( i = 1; i < 100; i++ ) {
console.log( 'nonfibonaccif(%d) = %d', i, nonfibonaccif( i ) );
}
C APIs
Usage
#include "stdlib/math/base/special/nonfibonaccif.h"
stdlib_base_nonfibonaccif( x )
Computes the nth non-Fibonacci single-precision floating-point number.
float out = stdlib_base_nonfibonaccif( 1 );
// returns 4.0f
out = stdlib_base_nonfibonaccif( 2 );
// returns 6.0f
The function accepts the following arguments:
- x:
[in] int32_t
input value.
float stdlib_base_nonfibonaccif( const int32_t x );
Examples
#include "stdlib/math/base/special/nonfibonaccif.h"
#include <stdio.h>
int main( void ) {
int i;
for ( i = 1; i < 12; i++ ) {
printf( "x: %i => result: %f", i , stdlib_base_nonfibonaccif( i ) );
}
}
References
- Gould, H.W. 1965. "Non-Fibonacci Numbers." Fibonacci Quarterly, no. 3: 177–83. <http://www.fq.math.ca/Scanned/3-3/gould.pdf>.
- Farhi, Bakir. 2011. "An explicit formula generating the non-Fibonacci numbers." arXiv abs/1105.1127 [Math.NT] (May): 1–5. <https://arxiv.org/abs/1105.1127>.