Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cleverLilly(input){
- let age = Number(input.shift());
- let priceWM = Number(input.shift());
- let singlePrToy = Number(input.shift());
- let countOfToy = 0;
- let money = 0;
- let incommingMoney = 10;
- for ( let i = 1; i <= age; i++) {
- if (i % 2 !== 0) {
- countOfToy += 1;
- } else {
- money += incommingMoney;
- incommingMoney += 10;
- money -= 1;
- }
- }
- money += countOfToy * singlePrToy;
- if (priceWM <= money) {
- console.log(`Yes! ${(money - priceWM).toFixed(2)}`);
- } else {
- console.log(`No! ${(priceWM - money).toFixed(2)}`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment