UNPKG

math_moraell

Version:

exemple et test de création de package

44 lines (38 loc) 783 B
var call_counter=require('./call_counter'); function multiple(x, y) { call_counter(); return x*y; } function divide(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; } /* function showFibo(x,y,n) { if (n>1) { return "" + (x+y) + ", " + fibo(y, (x+y), n-1) } else { return "" + (x+y); } }*/ module.exports={ multiplication:multiple, division:divide, fibonacci:fibo }