math_example_cvazquezm
Version:
An example of creating a package
36 lines (31 loc) • 689 B
JavaScript
var call_counter = require('./call_counter');
var simple_math = require('./simple_math');
function divide(x,y){
call_counter();
return x / y;
}
function multiply(x,y){
call_counter();
return x * y;
}
function fibo(count){
call_counter();
return private_fibo(count);
}
function private_fibo(count, counter, first, second) {
if (count == 0) return 0;
if (counter == undefined) {
counter = 1
first = 1;
second = 2;
}
result = first + second;
if (counter == count) return result;
private_fibo(count, ++counter, second, result)
return result;
}
module.exports = {
division : divide,
multiplication : multiply,
fibonacci : fibo
}