-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathremainderOf.js
34 lines (30 loc) · 939 Bytes
/
remainderOf.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
33
34
/**
* Given two positive, `n` and `d`, returns the remainder of `n` after
* dividing by `d`.
*
* Do not use the built-in modulo operator (`%`). The goal is to gain
* insight into how the modulo operator works.
*
* @example
* remainderOf(10, 1); // => 0
* remainderOf(10, 2); // => 0
* remainderOf(10, 3); // => 1
* remainderOf(10, 4); // => 2
* remainderOf(129, 17); // => 10
*
* @param {number} num The input number
* @returns {boolean} True if num is even and false otherwise
*/
function remainderOf(n, d) {
/*
This is your job. :)
If you're not sure, step out of the code and use pen + paper. Start
with simple examples and pay attention to the process you carry out.
*/
}
if (require.main === module) {
console.log('Running sanity checks for remainderOf');
// Add your own sanity checks here.
// How else will you be sure your code does what you think it does?
}
module.exports = remainderOf;