Non-Fibonacci

Compute the nth non-Fibonacci 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 nonfibonacci = require( '@stdlib/math/base/special/nonfibonacci' );

nonfibonacci( n )

Computes the nth non-Fibonacci number.

var v = nonfibonacci( 1 );
// returns 4

v = nonfibonacci( 2 );
// returns 6

v = nonfibonacci( 3 );
// returns 7

If provided either a non-integer or n < 1, the function returns NaN.

var v = nonfibonacci( -1 );
// returns NaN

v = nonfibonacci( 3.14 );
// returns NaN

If provided NaN, the function returns NaN.

var v = nonfibonacci( NaN );
// returns NaN

Examples

var nonfibonacci = require( '@stdlib/math/base/special/nonfibonacci' );

var v;
var i;

for ( i = 1; i < 100; i++ ) {
    v = nonfibonacci( i );
    console.log( 'nonfibonacci(%d) = %d', i, v );
}

References

Did you find this page helpful?