UNPKG

math-example_huntp

Version:

An example of creating a package

38 lines (30 loc) 791 B
var math_shared = require('./math_shared.js'); function _fibo(count, counter, first, second) { if (count == 0) { return 0; } counter = counter || 1; first = first || 1; second = second || 2; var result = first + second; if (counter == count) { return result; } return _fibo(count, ++counter, second, result); } function multiply(x, y) { math_shared.binary_operation( x, y, function (_x, _y) { return x * y }); } function divide(x, y) { math_shared.binary_operation( x, y, function (_x, _y) { return x / y }); } function fibo(n) { math_shared.unary_operation(n, _fibo); } module.exports = { multiplication: multiply, division: divide, fibonnaci: fibo }