Skip to content

Latest commit

 

History

History
183 lines (116 loc) · 3.64 KB

File metadata and controls

183 lines (116 loc) · 3.64 KB

FLOAT16_MAX_SAFE_NTH_TRIBONACCI

Maximum safe nth Tribonacci number when stored in half-precision floating-point format.

Usage

var FLOAT16_MAX_SAFE_NTH_TRIBONACCI = require( '@stdlib/constants/float16/max-safe-nth-tribonacci' );

FLOAT16_MAX_SAFE_NTH_TRIBONACCI

Maximum safe nth Tribonacci number when stored in half-precision floating-point format.

var bool = ( FLOAT16_MAX_SAFE_NTH_TRIBONACCI === 15 );
// returns true

Examples

var FLOAT16_MAX_SAFE_NTH_TRIBONACCI = require( '@stdlib/constants/float16/max-safe-nth-tribonacci' );

function tribonacci( n ) {
    var a;
    var b;
    var c;
    var d;
    var i;

    a = 0;
    b = 0;
    c = 1;
    if ( n === 0 ) {
        return a;
    }
    if ( n === 1 ) {
        return b;
    }
    if ( n === 2 ) {
        return c;
    }
    for ( i = 3; i <= n; i++ ) {
        d = a + b + c;
        a = b;
        b = c;
        c = d;
    }
    return c;
}

var v;
var i;
for ( i = 0; i < 100; i++ ) {
    v = tribonacci( i );
    if ( i > FLOAT16_MAX_SAFE_NTH_TRIBONACCI ) {
        console.log( 'Unsafe: %d', v );
    } else {
        console.log( 'Safe:   %d', v );
    }
}

C APIs

Usage

#include "stdlib/constants/float16/max_safe_nth_tribonacci.h"

STDLIB_CONSTANT_FLOAT16_MAX_SAFE_NTH_TRIBONACCI

Maximum safe nth Tribonacci number when stored in half-precision floating-point format.