Advertisement
Liliana797979

viarno reshenie combinations1

Feb 13th, 2021
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     n = Number(input[0]);
  3.     let combinations = 0;
  4.     for(let i = 0; i <= n; i++) {
  5.         for(let j = 0; j <= n; j++) {
  6.             for(let k = 0; k <= n; k++) {
  7.                 if (i + j + k == n) {
  8.                     combinations++;
  9.                 }
  10.             }
  11.         }
  12.     }
  13.     console.log(combinations);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement