Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function blackFlag(input) {
- let days = Number(input[0]);
- let dailyPlunder = Number(input[1]);
- let expectedPlunder = Number(input[2]);
- let totalPlunder = 0;
- for (let i = 1; i <= days; i++) {
- totalPlunder += dailyPlunder;
- if (i % 3 == 0) {
- totalPlunder += dailyPlunder * 0.5;
- }
- if (i % 5 == 0) {
- totalPlunder *= 0.7;
- }
- }
- if (totalPlunder >= expectedPlunder) {
- console.log(`Ahoy! ${totalPlunder.toFixed(2)} plunder gained.`);
- } else {
- console.log(`Collected only ${(totalPlunder / expectedPlunder * 100).toFixed(2)}% of the plunder.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement