-
Notifications
You must be signed in to change notification settings - Fork 22
/
multiply-recursive.js
32 lines (28 loc) · 1.08 KB
/
multiply-recursive.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict'
/*
* Create a function `multiply` that takes two number arguments
* and returns the result of the multiplication of those two.
* But you must do this without using the operators * or /
* and no loops, do it using recursion
*
* @notions Primitive and Operators, Functions, Recursion
* @next
*/
// Your code :
//* Begin of tests
const assert = require('assert')
assert.strictEqual(typeof multiply, 'function')
assert.strictEqual(multiply.length, 2)
assert.strictEqual(multiply.toString().includes('Math.imul'), false)
assert.strictEqual(multiply.toString().includes('while'), false)
assert.strictEqual(multiply.toString().includes('for'), false)
assert.strictEqual(multiply.toString().includes('*'), false)
assert.strictEqual(multiply.toString().includes('/'), false)
assert.strictEqual(multiply(34, 78), 2652)
assert.strictEqual(multiply(123, 0), 0)
assert.strictEqual(multiply(0, -230), 0)
assert.strictEqual(multiply(0, 0), 0)
assert.strictEqual(multiply(123, -22), -2706)
assert.strictEqual(multiply(-22, 123), -2706)
assert.strictEqual(multiply(-22, -123), 2706)
// End of tests */