@stdlib/math-base-special-nonfibonaccif
v0.1.1
Published
Compute the nth non-Fibonacci single-precision floating-point number.
Downloads
75
Readme
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.
Installation
npm install @stdlib/math-base-special-nonfibonaccifUsage
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 7If provided either a non-integer or n < 1, the function returns NaN.
var v = nonfibonaccif( -1 );
// returns NaN
v = nonfibonaccif( 3.14 );
// returns NaNIf provided NaN, the function returns NaN.
var v = nonfibonaccif( NaN );
// returns NaNExamples
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.0f );
// returns 4.0f
out = stdlib_base_nonfibonaccif( 2.0f );
// returns 6.0fThe function accepts the following arguments:
- x:
[in] floatinput value.
float stdlib_base_nonfibonaccif( const float x );Examples
#include "stdlib/math/base/special/nonfibonaccif.h"
#include <stdio.h>
int main( void ) {
float i;
float v;
for ( i = 1.0f; i < 12.0f; i++ ) {
v = stdlib_base_nonfibonaccif( i );
printf( "nonfibonaccif(%f) = %f\n", i, v );
}
}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>.
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.
