Skip to content

Commit

Permalink
solved #11: find next number divisible by 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophia committed Oct 21, 2017
1 parent ee9635c commit 94851f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions solutions/11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const find7m = (number, i = number) => {
if (i % 7 === 0) {
return i;
}
return find7m(number, i+1);
};
module.exports = find7m;


13 changes: 13 additions & 0 deletions test/11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const find7m = require('../solutions/11.js');
const test = (testNumber, result) => {
if (find7m(testNumber) === result) {
console.log(`Next number divisible by 7 is ${result}`);
} else {
console.log('False test!')
}
};

test(10,14); //true 14
test(-30, -28); //true -28
test(35,35); //true 35
test(35,21); //false test

0 comments on commit 94851f7

Please sign in to comment.