Advertisement
Spocoman

03. Combinations

Dec 30th, 2021
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function combinations(input) {
  2.     let num = parseInt(input[0]);
  3.     let counter = 0;
  4.     for (let a = 0; a <= num; a++) {
  5.         for (let b = 0; b <= num; b++) {
  6.             for (let c = 0; c <= num; c++) {
  7.                 if (a + b + c === num){
  8.                     counter++;
  9.                 }
  10.             }
  11.         }
  12.     }
  13.     console.log(counter);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement