Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function combinations(input) {
- let num = Number(input[0]);
- let combinationsCounter = 0;
- for (let x = 0; x <= num; x++) {
- for (let y = 0; y <= num; y++) {
- for (let z = 0; z <= num; z++) {
- if (x + y + z == num) {
- combinationsCounter++;
- }
- }
- }
- }
- console.log(combinationsCounter);
- }
Advertisement
Add Comment
Please, Sign In to add comment