Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const input = ['17'];
- const print = this.print || console.log;
- const gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- let n = +gets();
- let bearLegs = 2;
- let humanLegs = 5;
- let chickenLegs = 7;
- let count = 0;
- for (let bearLegsPair = 0; bearLegsPair <= Math.floor(n / bearLegs); bearLegsPair++) {
- for (let humanLegsPair = 0; humanLegsPair <= Math.floor(n / humanLegs); humanLegsPair++) {
- for (let chickenLegsPair = 0; chickenLegsPair <= Math.floor(n / chickenLegs); chickenLegsPair++) {
- let bear = bearLegs * bearLegsPair;
- let human = humanLegs * humanLegsPair;
- let chicken = chickenLegs * chickenLegsPair;
- let sum = bear + human + chicken;
- if (sum === n) {
- count++;
- }
- }
- }
- } print(count);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement