Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    continued-fractionpublic

    continued-fraction

    Continued fractions are pretty great.

    You can use them to compute transcendental real numbers!

    example

    e

    var cf = require('continued-fraction');
    var n = cf(
        function (n) { return (- 2) % 3 ? 1 : 2 * ((- 2) / 3) },
        function (n) { return 1 }
    );
    console.log(n);
    2.7182818284590455

    pi

    var cf = require('continued-fraction');
    var n = cf(
        function (n) { return 2 * (- 1) + 1 },
        function (n) { return n * n }
    );
    console.log(4/n);
    3.141592653589793

    methods

    var cf = require('continued-fraction');

    var n = cf(f, g)

    Evaluate a continued fraction given two functions f and g which will be evaluated with a parameter i, a set index starting at 1 for sets a and b of the generalized form.

    Returns a float n.

    install

    With npm do:

    npm install continued-fraction

    license

    MIT

    Keywords

    none

    install

    npm i continued-fraction

    Downloadsweekly downloads

    1

    version

    0.0.0

    license

    none

    repository

    github.com

    last publish

    collaborators

    • avatar