diff --git a/calculator/calculator.js b/calculator/calculator.js index 2d904a8..11e9500 100644 --- a/calculator/calculator.js +++ b/calculator/calculator.js @@ -1,25 +1,36 @@ -function add () { +function add (a,b) { + return a+b; +} + +function subtract (a,b) { + return a-b; +} + +function sum (a) { + let sum=0 + if(a){ + sum+=a; + } + return sum; +} + +function multiply (a,b) { + return a*b; +} + +function power(a,b) { + return Math.pow(a,b) } -function subtract () { - -} - -function sum () { - -} - -function multiply () { - -} - -function power() { - -} - -function factorial() { - +function factorial(a) { + if(a==o)return; + let fact=1; + for(let i=n ;i<0 ;i--) + { + fact*=1; + } + return fact; } module.exports = { @@ -29,4 +40,4 @@ module.exports = { multiply, power, factorial -} \ No newline at end of file +}