Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function party(args) {
- let companionsCount = +args[0];
- let totalCoins = 0;
- let days = +args[1];
- for (let i = 1; i <= +days; i++) {
- if (i % 10 === 0) {
- companionsCount -= 2;
- }
- if (i % 15 === 0) {
- companionsCount += 5;
- }
- totalCoins += (50 - (companionsCount * 2));
- if (i % 3 === 0) {
- totalCoins -= (companionsCount * 3);
- }
- if (i % 5 === 0) {
- totalCoins += (companionsCount * 20);
- }
- if (i % 3 === 0 && i % 5 === 0) {
- totalCoins -= (companionsCount * 2);
- }
- }
- let coins = Math.floor(totalCoins / companionsCount);
- console.log(`${+companionsCount} companions received ${+coins} coins each.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment