Non-Fibonacci

Compute the nth non-Fibonacci single-precision floating-point number.

The nth non-Fibonacci number is given by

f left-parenthesis n right-parenthesis equals left floor n plus 1 plus log Subscript phi Baseline left-parenthesis StartRoot 5 EndRoot left-parenthesis n plus 1 plus log Subscript phi Baseline left-parenthesis StartRoot 5 EndRoot left-parenthesis n plus 1 right-parenthesis right-parenthesis right-parenthesis minus 5 plus StartFraction 3 Over n plus 1 EndFraction right-parenthesis minus 2 right floor

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

Did you find this page helpful?