nikolayneykov

Untitled

Nov 6th, 2018
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function party(args) {
  2.     let companionsCount = +args[0];
  3.     let totalCoins = 0;
  4.     let days = +args[1];
  5.  
  6.     for (let i = 1; i <= +days; i++) {
  7.         if (i % 10 === 0) {
  8.             companionsCount -= 2;
  9.         }
  10.         if (i % 15 === 0) {
  11.             companionsCount += 5;
  12.         }
  13.         totalCoins += (50 - (companionsCount * 2));
  14.  
  15.         if (i % 3 === 0) {
  16.             totalCoins -= (companionsCount * 3);
  17.         }
  18.         if (i % 5 === 0) {
  19.             totalCoins += (companionsCount * 20);
  20.         }
  21.         if (i % 3 === 0 && i % 5 === 0) {
  22.             totalCoins -= (companionsCount * 2);
  23.         }
  24.     }
  25.  
  26.     let coins = Math.floor(totalCoins / companionsCount);
  27.     console.log(`${+companionsCount} companions received ${+coins} coins each.`);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment