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